A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
public partial class Wire : ObservableObject
{
[ObservableProperty]
Color bgColor{ get; set; }
.....
}
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
1.In XAML
<ListView x:Name="lvWires" ItemsSource="{Binding Wires}" >
<ListView.ItemTemplate >
<DataTemplate >
<ViewCell>
<StackLayout BackgroundColor="{Binding BgColor}">
<Label Text="Test" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
///////////////////////////////////////////////////////////////////
2.In VM
[ObservableProperty]
public ObservableCollection<Wire> wires;
Wires.Add(new Wire { BgColor = "Red" });
i had hard cord it to red but it is not updating in UI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
public partial class Wire : ObservableObject
{
[ObservableProperty]
Color bgColor{ get; set; }
.....
}
You have to implement INotifyPropertyChanged in your Wire class.
I think you can do something like
public partial class Wire : ObservableObject
{
[ObservableProperty]
string bgColor{ get; set; }
.....
}