Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Binding Brush property to a property inside of a List of Dictionary

Hi all,

I have a ViewModel class with this public property:
public List<Dictionary<int, DataModel>> Data { get; set; }


public double X { get; set; }
public int val {get; set;}
public string Color
return Legend.getColor(val); //return a string like "red" or "green", etc....


XAML file:
<ig:XamDataChart x:Name="BarChart">

<ig:NumericXAxis x:Name="XAxis"/>
<ig:CategoryYAxis x:Name="YAxis" ItemsSource="{Binding Data}"/>

x:Name="StackedSeries" ItemsSource="{Binding Data}"
XAxis="{x:Reference XAxis}"
YAxis="{x:Reference YAxis}" Brush="{Binding [Value].Color}"> <!-- Brush property doesn't work -->



CB = new ViewModel();
BarChart.BindingContext = CB;

for (int k = 0; k < CB.maxArraySize ; k++)
string key = "[" + k.ToString() + "]";
StackedFragmentSeries seriesFragment = new StackedFragmentSeries();
seriesFragment.ValueMemberPath = key+"[X]";

I want to bind the Brush property of the StackedSeries to the Color property of DataModel.
I would like that each fragment of each series has a chosen color.
Actually, if I don't set the Brush property, all first fragments have the same green color, all second fragments have the same cyan color, etc... like the image in attachment.
The "behavior" of Brush property to get Color value, should be the same of ValueMemberPath.

I tried with
Brush="{Binding [Value].Color}" // List<Dictionary<int, DataModel>> where DataModel has Color property.
but it doesn't work.

Any ideas please?

Thanks to all for your support.