This is a migrated thread and some comments may be shown as answers.

How to bind color

1 Answer 160 Views
Chart
This is a migrated thread and some comments may be shown as answers.
ardmore
Top achievements
Rank 1
ardmore asked on 02 Nov 2017, 11:41 PM
<telerik:RadLegend Grid.Row="1" Margin="10,20" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <telerik:RadLegend.Items>
                        <telerik:LegendItemCollection>
                            <telerik:LegendItem MarkerFill="Red" Title="Legend item 1" />
                            <telerik:LegendItem MarkerFill="Green" Title="Legend item 2" />
                            <telerik:LegendItem MarkerFill="Blue" Title="Legend item 3" />
                            <telerik:LegendItem MarkerFill="Aqua" Title="Legend item 4" />
                        </telerik:LegendItemCollection>
                    </telerik:RadLegend.Items>
                </telerik:RadLegend>
I want to add legends to doughnut char. Now the colors are hard coded in xaml. But I want to use MVVM. Not sure how to bind it? 

1 Answer, 1 is accepted

Sort by
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 07 Nov 2017, 04:03 PM
Hi Hui,

MarkerFill is not a Dependency property, so you cannot bind to it. However, what you can do is create a LegendItemCollection in your view model and then set the Items property of the RadLegend.
I am attaching a sample project for your reference. Please take a look at it and see how it fits you scenario.

I hope this helps. Don't hesitate to contact us again if you have any further questions.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Chart
Asked by
ardmore
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Share this question
or