开发者

"Object reference not set to an instance of an object." when setting a listview template

I'm trying to switch between 2 templates on the basis of a data t开发者_运维技巧rigger. But I app crashes with the "Object reference not set to an instance of an object." If I comment out the setter for the template it runs fine.

Here's my XAML:

<Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
        <Setter Property="Template" Value="{StaticResource Default}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding Path=FlagVar}" Value="true">
                <Setter Property="Template" Value="Error"/>
                <Setter Property="Background" Value="{DynamicResource ListErrorBackgroundColor}"/>
                <Setter Property="IsSelected" Value="False"/>
            </DataTrigger>
        </Style.Triggers>
</Style>

EDIT- The above styling is in a ResourceDictionary which is merged into the consuming XAML.


What is the Value="Error" means? you can't set the Template like that, check this article

http://msdn.microsoft.com/en-us/library/ms788717(VS.85).aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜