asListBox
にバインドされたコントロールがあります。中にはand (両方の文字列) があります。の中でバインドされます。今、私がやりたいのは、に基づいて選択されたカテゴリの色を変更することです。私はすでに文字列を返すブラシする文字列を持っています。また、ページ リソースでも正しく定義されています。私は変わる必要があることを知っています。現在、私は次のようなものを持っています:ObservableCollection<ToDoCategory>
ItemsSource="{Binding Categories}
ToDoCategory
CategoryName
CategoryColor
CategoryName
ItemTemplate
ListBox
CategoryColor
IValueConverter
SolidColorBrush
ItemContainerStyle
<Style x:Key="CategoryListBoxContainerStyle" TargetType="ListBoxItem">
Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border...>
<VisualStateManager.VisualStateGroups>
<VisualState x:Name="Selected">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="InnerGrid">
<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding CategoryColor, Converter=StringToBrushConverter}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ListBoxItemSelectedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
.
.
.
</style>
これはうまくいきません。CategoryColor
InnerGridのBackground を にバインドするにはどうすればよいToDoCategory
ですか?