I am trying to set the Grid.Column property using a datatrigger:
<Style TargetType="ListBox">
<Style.Triggers>
<DataTrigger Binding="{Binding View}" Value="HistoryLeft">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
<DataTrigger Binding="{Binding View}" Value="HistoryRight">
<Setter Property="Grid.Column" Value="0"/>
<Setter Property="Grid.ColumnSpan" Value="2"/>
</DataTrigger>
</Style.Triggers>
</Style>
The Grid.ColumnSpan works fine but the Grid.Column does not set. Any ideas?
The XAML for the Listbox is:
<ListBox ItemsSource="{Binding HistoryItemsRight}" BorderThickness="0,1,0,0" Grid.Row="0" Grid.Column="1" ItemsPanel="{StaticResource NoHorizontalScroll}" Background="White" ScrollViewer.VerticalScrollBarVisibility="Visible"
HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource HistoryItem}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.Style>
<Style TargetType="ListBox">
<Style.Triggers>
<DataTrigger Binding="{Binding View}" Value="HistoryLeft">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
<DataTrigger Binding="{Binding View}" Value="HistoryRight">
<Setter Property="Grid.Column" Value="0"/>
<Setter Property="Grid.ColumnSpan" Value="2"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListBox.Style>
<ListBox.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/HistoryViewTemplates.xaml"/>
<ResourceDictionary>
<DataTemplate DataType="{x:Type viewModel:HistoryItemView}">
<Grid Style="{StaticResource HistoryItemGrid}">
<Grid.ToolTip>
<controls:HistoryViewToolTip></controls:HistoryViewToolTip>
</Grid.ToolTip>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" MinWidth="30"/>
<ColumnDefinition Width="60" MinWidth="50"/>
<ColumnDefinition Width="250*" MinWidth="100"/>
</Grid.ColumnDefinitions >
<TextBlock Text="{Binding Date, StringFormat=' HH:mm:ss'}" Grid.Column="1"/>
<TextBlock Text="{Binding Path}" Grid.Column="2" HorizontalAlignment="Stretch"/>
<Button FontWeight="Bold" Padding="2,0,2,0" Margin="0,0,2,0" Width="19" Command="{Binding OperationToRight}" Grid.Column="0" Style="{StaticResource RightSideHistoryButton}" />
</Grid>
</DataTemplate>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</ListBox.Resources>
</ListBox>