Reputation: 205
I want to set Fill Color property of Ellipse via data binding, I have tried many ways so far was unsucessfull in setting it. Below is my XAML and VioewModel.cs code.
<Ellipse x:Name="ClipEllipse" Fill="{Binding EllipseColor}"></Ellipse>
public System.Windows.Media.Color EllipseColor
{
get
{
Random r = new Random();
return System.Windows.Media.Color.FromRgb((byte)r.Next(255), (byte)r.Next(255), (byte)r.Next(255));
}
}
Upvotes: 1
Views: 325
Reputation: 4164
You need to set the data context ( which is your view model with property EllipseColor)
In code behind of xaml.cs file - try setting DataContext=new ViewModel()
in constructor.
Upvotes: 1