Triggers inside PointSeries DefaultVisualStyle for accessing DataPoint.IsSelected

3 posts, 0 answers
  1. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 06 Apr Link to this post

    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. Sivakumar
    Sivakumar avatar
    27 posts
    Member since:
    Dec 2015

    Posted 06 Apr Link to this post

    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>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 08 Apr Link to this post

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