当我使用下面的代码它的工作,因为我使用一个ListBox支持算法FMP财产不ListView控件
<UserControl.Resources>
<Style BasedOn="{StaticResource {x:Type ListBox}}" TargetType="{x:Type ListBox}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Background" Value="Transparent" />
</Style>
</UserControl.Resources>
但是,当我使用下面的代码到ListView我得到一个警告/异常工作
<UserControl.Resources>
<Style BasedOn="{StaticResource {x:Type ListView}}" TargetType="{x:Type ListView}">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Background" Value="Transparent" />
</Style>
</UserControl.Resources>
“StaticResource reference'System.Windows.Controls.ListView'was not found。”
为什么以及如何解决它?我想要一个ListView的功能。
为什么你需要'BasedOn = ...'? – Heinzi 2010-04-11 23:53:16
Heinzi看到这个:http://stackoverflow.com/questions/2593042/datatemplates-while-using-theme-does-not-work-wpf :) – 2010-04-12 00:21:47
好的,所以你想要你的风格基于预先存在的风格(取自某个主题)。但是,错误消息只是说“ListView没有预先存在的风格”,所以你应该只需要将'BasedOn = ...''离开即可。 – Heinzi 2010-04-13 21:50:40