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