How to bind color

2 posts, 1 answers
  1. ardmore
    ardmore avatar
    24 posts
    Member since:
    Jul 2016

    Posted 02 Nov 2017 Link to this post

    <telerik:RadLegend Grid.Row="1" Margin="10,20" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                <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" />
    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? 
  2. Answer
    Vladimir Stoyanov
    Vladimir Stoyanov avatar
    110 posts

    Posted 07 Nov 2017 Link to this post

    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.

    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.
Back to Top