一个DataTemplate
里面Resource Dictionary
需要引用一个Styles.xaml
,所以我有以下内容
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:WPFApp">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="resources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type src:MyFileInfo}">
<Grid>
grid stuff
</Grid>
<TextBlock> stuff </TextBlock>
</DataTemplate>
</ResourceDictionary>
但是DataTemplate
说这The proprety "Visual Tree" can only be set once.
是什么意思有误?将DataTemplate
内部放进去是一种好习惯ResourceDictionary
吗?如何访问a中的其他资源ResourceDictionary
?
一个DataTemplate应该只有一个孩子。用这个:
<DataTemplate DataType="{x:Type src:MyFileInfo}">
<Grid>
grid stuff
<TextBlock> stuff </TextBlock>
</Grid>
</DataTemplate>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句