このサイトのさまざまな例を試して、リスト ボックス/チェック ボックスのコンボをデフォルトのグレーから別の色に変更して無駄にしました。
私が最終的にやろうとしているのは、アイテムがチェックされている場合、背景は白になり、チェックされていない場合は灰色になります.
ここに私が持っているものがあります。
リソースを以下のコメントに更新します。
コントロールは返信に更新されましたが、まだ機能していません。何かアイデアはありますか?
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding}"
Name="lstSwimLane" SelectionMode="Multiple"
Width="auto"
Height="auto"
Background="Transparent"
BorderThickness="0"
SelectionChanged="LstSwimLaneSelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="IsSelected" Value="{Binding Path=IsChecked, Mode=TwoWay}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="Border" SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="{StaticResource SelectedBrush}"/>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="{StaticResource UnselectedBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="3,3,3,3">
<CheckBox IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
Checked="ChkFilterChecked"
Unchecked="ChkFilterUnchecked"
VerticalAlignment="Center"
Margin="0,0,4,0" />
<TextBlock Text="{Binding Value}" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
注: チェックされたチェックボックスとリスト項目の組み合わせは灰色のままで、チェックされていないものは白です。
以下の返信に一致すると思われるスクリーンショットを添付します。私は困惑しています。
画像を大きく表示するための直接リンクは次のとおりです。
http://s1120.photobucket.com/albums/l489/nitefrog/?action=view¤t=jw_0012011-03-311325.jpg
チェックボックスのスクリーンショットを次に示します。
http://i1120.photobucket.com/albums/l489/nitefrog/jw_0022011-03-311345.jpg
ブラシが設定されているにもかかわらず、何らかの理由でそれらがトリガーされていません。
何か案は?
ありがとう。