When I use the following code it works because I am using a ListBox
<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>
But when I use the following code to a ListView I get an warning/exception
<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.开发者_如何学PythonListView' was not found."
Why and how to solve it? I want the functionality of a ListView.
Try this one:
<Style BasedOn="{StaticResource {x:Type ListBox}}" TargetType="{x:Type ListView}">
A ListView
does not handle presentation, it delegates this to its View
property, which is usually a GridView
. Try setting the style using the GridView
type as key.
I'm having the same problem. my scenario is little complicated: app1 references lib1 and lib2, lib1 defines the listview style, lib2 defines a user control containing a listview and has no idea about the listview style. app1 adds the resource dictionary:
in lib2, I define list view like this:
at design time, I got the error: StaticResource reference 'System.Windows.Controls.ListView' was not found. but at runtime, it works well. I guess this is a bug of VS2008. I tried it on VS2010 which does not have this design time error.
精彩评论