DataTemplate
如何應用於Grid
?將DataTemplate應用於網格
我在Resources.xaml
文件DataTemplate
名爲DataGrid_Template,我想申請到Grid
在View.xaml。
Resources.xaml
<ResourceDictionary ... >
<DataTemplate x:Key="DataGrid_Template">
<Grid>
<Grid.RowDefinitions ... />
<DockPanel ... />
<DataGrid ... />
</Grid>
</DataTemplate>
</ResourceDictionary>
View.xaml
<UserControl ... >
<Grid /> <!-- want to apply DataGrid_Template to this -->
</UserControl>
我嘗試使用Grid
財產TemplatedParent
,但似乎是隻讀的屬性。
你們是不是要使用Grid作爲'ItemsControl',還是更復雜的東西? – Tyrsius 2012-07-10 19:47:41
看到這些鏈接:http://stackoverflow.com/questions/3251081/is-there-a-datatemplate-for-grid-panel-elements-in-wpf,http://stackoverflow.com/questions/3223174/changing -wpf-stackpanel-template - >你不能直接使用 – Clueless 2012-07-10 19:50:12
@Tyrsius我沒有使用'Grid'作爲'ItemsControl'。查看「Resources.xaml」的更新代碼片段。我想要一個'DockPanel'和一個'DataGrid'。 – mauryat 2012-07-10 20:11:11