私はグリッドビューを持っています:
<GridView xmlns:controls="using:Windows.UI.Xaml.Controls">
<GridView.ItemTemplate>
<DataTemplate>
<Grid>
<Image Source="{Binding Image}"></Image>
<Grid Height="50" Width="50" Background="{Binding Color}"></Grid>
<TextBlock FontSize="25" TextWrapping="Wrap" Text="{Binding Name}" Margin="10,10,0,0"/>
</Grid>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
これはobservablecollectionにバインドされています:
ObservableCollection<KeyItem> Keys = new ObservableCollection<KeyItem>();
Keys.Add(new KeyItem { Name = "jfkdjkfd" });
Keys.Add(new KeyItem { Name = "jfkdjkfd" });
myView.ItemsSource = Keys;
キーアイテムはこれです:
public class KeyItem
{
public string Name { get; set; }
public ImageSource Image { get; private set; }
public Brush Color
{
get;
set;
}
}
これは、itemssourceに割り当てる前に色を設定すると正常に機能します。
ただし、KeyItemが割り当てられた後、プログラムでColorプロパティを変更し、Bindingで色を変更できるようにする必要もあります。しかし、この構成では、これは機能していません。
これを機能させるための最良のアプローチは何でしょうか?