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
45
Usage of DataContext for LegendItem
posted

Hello Everybody,

I have faced with the following situation which I cannot resolve myself,

I need to set an Icon in the legend item, and have created the following LegentItem Style.

<Style x:Key="LegendItemIconStyle" TargetType="ig:LegendItem">

        <Setter Property="IsTabStop" Value="False"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="ig:LegendItem">

                    <StackPanel Orientation="Horizontal" Margin="0,0,0,0">

                        <Image Width="12" Height="12" Margin="12,2,12,6" 

                                     Source="{Binding Path=BitmapSource, Mode=TwoWay}" />

                        <ig:Title Content="{TemplateBinding Content}" />                        

                    </StackPanel>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

But I have no idea how I can get access to the DataContext of the LegendItem. On DateTimeSerie I cannot get access to it. So probably I am doing this wrong and  there is a better way of doing that. So basically the request is to show an icon and to bind it to the Source Property somehow.

 

Any help would be very appreciated,

Reagards,

Kirill

Parents
No Data
Reply
  • 17605
    posted

    Hi,

    You can specify the Legend Item per series style with Series.LegendItemStyle property. You can modify the following code:

            <ig:XamTimeline>

                <ig:XamTimeline.Series>

                    <ig:NumericTimeSeries Title="Series 1">

                        <ig:NumericTimeSeries.LegendItemStyle>

                            <Style TargetType="ig:LegendItem">

                                <Setter Property="IsTabStop" Value="False"/>

                                <Setter Property="Template">

                                    <Setter.Value>

                                        <ControlTemplate TargetType="ig:LegendItem">

                                            <StackPanel Orientation="Horizontal">

                                                <!--<Image Source="imageSource" /> static image source -->

                                                <Ellipse Width="8"

                                                         Height="8"

                                                         Fill="{TemplateBinding Fill}"

                                                         Stroke="{TemplateBinding Stroke}"

                                                         StrokeThickness="1" />

                                                <ig:Title  Content="{TemplateBinding Content}"

                                                           Margin="5,0,0,0"

                                                           Foreground="{TemplateBinding Foreground}" />

                                            </StackPanel>

                                        </ControlTemplate>

                                    </Setter.Value>

                                </Setter>

                            </Style>

                        </ig:NumericTimeSeries.LegendItemStyle>

                    </ig:NumericTimeSeries>

     

                </ig:XamTimeline.Series>

            </ig:XamTimeline>

     

Children