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
1415
Custom Legend Brushes
posted

We are binding a BrushCollection to the XamDataChart as shown:

<ig:XamDataChart Legend="{Binding ElementName=XmLegend}" Brushes="{Binding MyBrushes}">

and then creating our own LegendTemplate for the column series as shown:

DataTemplate x:Key="LegendTemplate">
                        <Border Visibility="{Binding Series.Visibility}">
                            <StackPanel Orientation="Horizontal">
                                <Rectangle 
                                    Fill="{Binding Series.Brush}"
                                    Width="10" Height="10" 
                                    Margin="2"/>
                                <ContentPresenter Content="{Binding Series.Title, TargetNullValue=Series Title}" Margin="2" ></ContentPresenter>
                            </StackPanel>
                        </Border>
                    </DataTemplate>

but  Fill="{Binding Series.Brush}" does not seem to pick up the binded brush collection.  We can see this work if the Brushes are assigned to each individual column series, but the legend does not display colors when a collection is bounded to the data charts  "Brushes" attribute.

Is there another attribute we can tap into in order to leverage the binded BrushCollection for our custom legend template?

Parents
  • 34830
    Verified Answer
    Offline posted

    Hello PMac,

    I have been investigating into your requirement to bind the series brush in this case, and in this case, I would recommend binding to {Binding Series.ActualBrush} instead.

    The Brush property will only be populated with a value if you explicitly set it on the Series itself, whereas the ActualBrush will be the resolved color of the series.

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data