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

Triggers inside PointSeries DefaultVisualStyle for accessing DataPoint.IsSelected

2 Answers 45 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Sivakumar
Top achievements
Rank 1
Sivakumar asked on 06 Apr 2016, 09:22 AM

I am trying set selected point color using triggers.But it is not working.Is there anyway to access to IsSelected property ?

Or Do we need to go for point template(Working here)?

<telerik:PointSeries.DefaultVisualStyle>
    <Style TargetType="Path">
          <Setter Property="Fill" Value="YellowGreen"/>
          <Setter Property="Stroke" Value="Red"/>
          <Setter Property="StrokeThickness" Value="1"/>
     <Style.Triggers>
                    <DataTrigger Binding="{Binding DataPoint.IsSelected}" Value="True">
                        <Setter Property="Fill" Value="Red" />
                    </DataTrigger>
                    
                </Style.Triggers>
    </Style>
</telerik:PointSeries.DefaultVisualStyle>

2 Answers, 1 is accepted

Sort by
0
Sivakumar
Top achievements
Rank 1
answered on 06 Apr 2016, 10:17 AM
One more issue i am facing one same above,I am trying to set Fill value of Point based on conditions but it is not working as well .My model has IsPass property.
 
 <Style x:Key="PointSeriesStyle" TargetType="telerik:PointSeries">
                <Setter Property="ShowLabels" Value="True" />
                <Setter Property="CategoryBinding" Value="Vector" />
                <Setter Property="ValueBinding" Value="ValueForDisplay1" />
                <!--<Setter Property="DefaultVisualStyle" Value="{StaticResource PointTempalteStyle}" />-->
                <Setter Property="DefaultVisualStyle">
                    <Setter.Value>
                        <Style TargetType="Path">
                            <Setter Property="Fill" Value="Yellow"/>
                            <Setter Property="Stroke" Value="Transparent"/>
                            <Setter Property="StrokeThickness" Value="0"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding DataItem.IsPass}" Value="False">
                                    <Setter Property="Fill" Value="Red" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Setter.Value>
                </Setter>
0
Martin Ivanov
Telerik team
answered on 08 Apr 2016, 11:18 AM
Hi Sivakumar,

The trigger doesn't work because it cannot find the path to the IsPass and IsSelected properties. In order to access the data point model in the DefaultVisualStyle you will need to use the Path element Tag property. 
<telerik:PointSeries.DefaultVisualStyle>
    <Style TargetType="Path">      
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Tag.DataItem.IsSelected}" Value="True">
                <Setter Property="Fill" Value="Red" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</telerik:PointSeries.DefaultVisualStyle>
Basically, this binding says - get the Path element (self), then get its Tag property which contains the DataPoint model. After this, get the DataPoint's DataItem property which is the view model and get its IsSelected property.

Regards,
Martin
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ChartView
Asked by
Sivakumar
Top achievements
Rank 1
Answers by
Sivakumar
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or