當我使用下面的代碼它的工作,因爲我使用一個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