开发者

WP7: ListBox Style in DataTemplate throwing parser error

开发者 https://www.devze.com 2023-02-20 17:35 出处:网络
I have a Style which looks like this: <Style x:Name=\"SomeListBoxStyle\" TargetType=\"ListBox\">

I have a Style which looks like this:

<Style x:Name="SomeListBoxStyle" TargetType="ListBox">
    <Setter Property="Template">
        <Setter.Value>
            <DataTemplate>
                <Grid Margin="5,5,5,5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70"/>
                        <ColumnDefinition Width="75"/>
                        <ColumnDefinition Width="75"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <!-- Rest of template is commented out - error still occurs. -->
                </Grid>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

And a ListBox:

<ListBox x:Name="SomeListBox" Grid.Row="0" SelectionMode="Single" Style="{StaticResource SomeListBoxStyle}" Visibility="Collapse开发者_JS百科d" SelectionChanged="SomeListBox_SelectionChanged"/>

Upon running, I get the (very helpful) error:

AG_E_UNKNOWN_ERROR [Line: 22 Position: 211]

This error points to the last attribute of the ListBox (no matter what the last attribute is). How am I applying this DataTemplate incorrectly?


Try changing Property="Template" to Property="ItemTemplate"

0

精彩评论

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

关注公众号