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

Get parent grid view row IsSelectionActive Property

5 Answers 291 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kavita
Top achievements
Rank 1
Kavita asked on 10 May 2013, 08:00 AM
HI,

My grid view contains number of rows and one column in the grid view contains a list box.

I am using the below code to change the color of textblock placed inside the list box based on its parent grid view row.

<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">

<Style.Triggers>

<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewRow}}, Path=IsSelected}" Value="True">

<Setter Property="Foreground" Value="White" />

</DataTrigger>
</Style.Triggers>

</Style>



Though its working fine but i want one more condition in this trigger to check wheather Parent grid view selected row's selection is active or not.For that i modified condition inside the trigger as mentioned below:

<
MultiDataTrigger>
<Condition
 Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewRow}}, Path=IsSelected}" Value="true"/>
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewRow}}, Path=Selector.IsSelectionActive}" Value="true"/>
</
MultiDataTrigger>

But its not working. Can you please suggest which approach to use to get parent row's Selector.IsSelectionActive property.

Looking forward for your reply.
Thanks And Regards,
Kavita

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 10 May 2013, 08:09 AM
Hi,

You are trying to read an attached property ( Selector.IsSelectionActive ) .By default the row does not have such property set .In case you do not set such attach property explicitly - it will not be present for the row.


Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kavita
Top achievements
Rank 1
answered on 10 May 2013, 09:11 AM
But in normal caes this property works actually..
I applied below triggers in grid view row :

<ControlTemplate TargetType="{x:Type telerik:GridViewRow}"><telerik:SelectiveScrollingGrid x:Name="grid">

 

<telerik:SelectiveScrollingGrid.RowDefinitions>

 

<RowDefinition Height="50"/>

 

<RowDefinition/>
</telerik:SelectiveScrollingGrid.RowDefinitions>

 

<Border x:Name="itemBorder" BorderBrush="{DynamicResource telerikListItemBorderBrush}" BorderThickness="1,0,0,1"

 

Padding="{TemplateBinding Padding}" Background="{DynamicResource telerikListItemBackgroundBrush}"/>

 

<telerik:DataCellsPresenter Height="Auto" FocusVisualStyle="{x:Null}" Focusable="False" MinHeight="{TemplateBinding MinHeight}" x:Name="PART_DataCellsPresenter" />

 

<telerik:DetailsPresenter x:Name="PART_DetailsPresenter" Visibility="Collapsed" Grid.Row="1" DetailsProvider="{TemplateBinding DetailsProvider}"/>

 

</telerik:SelectiveScrollingGrid >

 

<ControlTemplate.Triggers>

 

<MultiTrigger>

 

<MultiTrigger.Conditions>

 

<Condition Property="IsSelected" Value="true"/>

 

<Condition Property="Selector.IsSelectionActive" Value="true"/>

 

</MultiTrigger.Conditions>

 

<Setter TargetName="itemBorder" Property="Background" Value="{DynamicResource selectedListItemBackgroundBrush}"/>

 

<Setter TargetName="PART_DetailsPresenter" Property="Background" Value="{DynamicResource selectedListItemBackgroundBrush}"/>

 

</MultiTrigger>

 

<Trigger Property="Visibility" Value="Visible" SourceName="PART_DetailsPresenter">

 

<Setter TargetName="itemBorder" Property="BorderThickness" Value="1,0,0,0"/>

 

</Trigger>

 

</ControlTemplate.Triggers>

 

</ControlTemplate>

and it works perfectly...
My issue is to access this property from parent row.

Is there any other way by which i can change the color of text block based on selected item and its active state?



0
Pavel Pavlov
Telerik team
answered on 10 May 2013, 02:14 PM
Hi,

To be honest I am a bit confused that this actually works. Definitely telerik: RadGridView does not use , set or handle the Selector.IsSelectionActive property.

Unfortunately GridView row does not expose a property to define whether the "selection is active".


Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kavita
Top achievements
Rank 1
answered on 13 May 2013, 05:06 AM
But its actually working here.

Anyways is there any way to apply a trigger  only when row is selected and in active state.
0
Pavel Pavlov
Telerik team
answered on 13 May 2013, 03:04 PM
Hello,

Unfortunately GridView row does not expose a property to define whether the "selection is active".
So adding such trigger would not be possible.

Kind regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Kavita
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Kavita
Top achievements
Rank 1
Share this question
or