wpf - How to re-use grid definitions from ResourceDictionary? -
i'm trying re-use grid defined under resourcedictionary(guilayout.xaml)
guilayout.xaml
<resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <grid x:key="guilayout"> <grid.rowdefinitions> <rowdefinition height="10"/> <rowdefinition height="*"/> </grid.rowdefinitions> </grid>
and have mainwindow.xaml,
<window x:class="wpfapplication3.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid> <!-- want utilize resourcedictionary definitions here--> </grid>
is possible utilize grid definition guilayout.xml
in mainwindow.xaml
?
edit:
the project looks this,
you can set content
of window
in xaml this:
<window x:class="wpfapplication3.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" content="{staticresource guilayout}"> </window>
or using element syntax:
<window x:class="wpfapplication3.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <window.content> <staticresource resourcekey="guilayout"/> </window.content> </window>
note without using x:shared
grid
saved resource, grid
usable 1 window. utilize multiple windows, have add together x:shared="false"
grid
this:
<grid x:key="guilayout" x:shared="false"> <!-- ... --> </grid>
update: seek code import resources:
in app.xaml:
<application.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="resources\guilayout.xaml"/> </resourcedictionary.mergeddictionaries> </resourcedictionary> </application.resources>
wpf xaml resourcedictionary
No comments:
Post a Comment