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"
精彩评论