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

selectionchanged strange behavior when using rowstyle

11 Answers 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bart Reekmans
Top achievements
Rank 1
Bart Reekmans asked on 13 Jun 2012, 01:01 PM

Hi,

I am using a rowstyleselector, but the griditem gets only selected when one of the controls inside the style template is clicked.
Clicking in an empty area between the controls in the template does NOT result in the item being selected (tested by subscribing to the SelectionChanged event) Using a single column with a cellstyleselector is not an option for me, since it does not correctly stretches its content according to the radgridview-width. Any ideas on this? (We are using the latest version 2012 Q1)

11 Answers, 1 is accepted

Sort by
0
Bart Reekmans
Top achievements
Rank 1
answered on 14 Jun 2012, 06:31 AM
Hi,

This issue is fixed when I set the background to "Transparent" : 

<selectors:RowStyleSelector.patientviewHorizontal>
            <Style TargetType="telerik:GridViewRow">
                <Setter Property="Template" Value="{StaticResource PatientViewTemplate}" />
                <Setter Property="Background" Value="Transparent" />
            </Style>
</selectors:RowStyleSelector.patientviewHorizontal>

What is the best way to get the default selected and mouseover colors back (since they are now overridden by the rowstyle)?
0
Dimitrina
Telerik team
answered on 14 Jun 2012, 06:47 AM
Hi,

 In regard to your question, I would recommend you to use a background that has some percent transparency. For example you could try White 30% transparent background: 

Background="#4CFFFFFF"

Does it help?

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bart Reekmans
Top achievements
Rank 1
answered on 14 Jun 2012, 01:59 PM
I've tried this:

<ControlTemplate x:Key="PatientViewTemplate" TargetType="telerik:GridViewRow">
    <views:PatientView Background="#4CFFFFFF"/>
</ControlTemplate>
 
<ControlTemplate x:Key="PatientViewVerticalTemplate" TargetType="telerik:GridViewRow">
    <views:PatientViewVertical Background="#4CFFFFFF"/>
</ControlTemplate>
 
<selectors:RowStyleSelector x:Key="aaaaaaaaaaaaaa">
    <selectors:RowStyleSelector.patientviewHorizontal>
        <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
            <Setter Property="Template" Value="{StaticResource PatientViewTemplate}" />
        </Style>
    </selectors:RowStyleSelector.patientviewHorizontal>
    <selectors:RowStyleSelector.patientviewVertical>
        <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
            <Setter Property="Template" Value="{StaticResource PatientViewVerticalTemplate}" />               
        </Style>
    </selectors:RowStyleSelector.patientviewVertical>
</selectors:RowStyleSelector>


But it doesn't help.
0
Dimitrina
Telerik team
answered on 15 Jun 2012, 02:26 PM
Hello,

 I am not sure what would be wrong in that case. May you please confirm the exact version of the binaries do you use? Would it be possible for you to send me a simple test project which we could debug at our end?

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bart Reekmans
Top achievements
Rank 1
answered on 19 Jun 2012, 01:49 PM
Hi,

I changed the XAML of my selector into : 

<selectors:RowStyleSelector x:Key="aaaaaaaaaaaaaa">
        <selectors:RowStyleSelector.patientviewHorizontal>
            <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
                <Setter Property="Template" Value="{StaticResource GridViewRowTemplate}" />
                <Setter Property="Background" Value="#4CFFFFFF"/>
            </Style>
        </selectors:RowStyleSelector.patientviewHorizontal>
...

and this works (mouseover and selected color visible).
When using my own ControlTemplate, the selection- and mouse- background are overridden; probably because I'm using the Binaries.NoXaml (GridViewRowTemplate defined in Telerik.Windows.Controls.GridView.xaml 2012.2.607.35)?

I suppose I have to redefine the selection- and mouse- background?
0
Dimitrina
Telerik team
answered on 19 Jun 2012, 02:14 PM
Hi,

 I would recommend you to check this help article where you could find details on how to apply styles and themes based on the binaries used.

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bart Reekmans
Top achievements
Rank 1
answered on 20 Jun 2012, 01:31 PM
I already took a look at this article, the theming works for all other controls.
I changed the code to : 

<selectors:RowStyleSelector x:Key="aaaaaaaaaaaaaa">
        <selectors:RowStyleSelector.patientviewHorizontal>
            <Style TargetType="telerik:GridViewRow" BasedOn="{StaticResource GridViewRowStyle}">
            </Style>
        </selectors:RowStyleSelector.patientviewHorizontal>
...

And now the highlighting and selection colors work.
So I must be overriding some style by setting the template?

Edit : the same problem is visible in your telerik wpf demos gridview - appearance - custom row layout.
This demo also uses a custom rowstyle, but selection and highlighting colors are not visible.
0
Dimitrina
Telerik team
answered on 21 Jun 2012, 10:37 AM
Hi,

 Thank you for the shared observations. I have checked the demo you mentioned but actually this is expected. You have to add the highlighting colours yourself.

Please check this forum thread for a reference.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bart Reekmans
Top achievements
Rank 1
answered on 21 Jun 2012, 01:24 PM
This example is for Silverlight and uses VisualStateManager. 
This was added to WPF in .NET 4?
I'm using framework 3.5
0
Vanya Pavlova
Telerik team
answered on 21 Jun 2012, 01:54 PM
Hi Chris,

 

You may define your own Triggers for this ControlTemplate and manipulate the elements you need. 
Please check MSDN for further reference. 



Greetings,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Bart Reekmans
Top achievements
Rank 1
answered on 21 Jun 2012, 02:09 PM
I looked up the triggers in the gridview xaml and came to the following solution : I added these triggers to my controltemplate : 

<ControlTemplate x:Key="PatientViewTemplate" TargetType="telerik:GridViewRow">
       <views:PatientView x:Name="zzz" Background="Transparent"/>
       <ControlTemplate.Triggers>
           <MultiTrigger>
               <MultiTrigger.Conditions>
                   <Condition Property="IsMouseOver" Value="True" />
                   <Condition Property="DisplayVisualCues" Value="True" />
               </MultiTrigger.Conditions>
               <Setter TargetName="zzz" Property="Background" Value="#F1F1F1" />
           </MultiTrigger>
           <MultiTrigger>
               <MultiTrigger.Conditions>
                   <Condition Property="IsSelected" Value="True" />
                   <Condition Property="DisplayVisualCues" Value="True" />
               </MultiTrigger.Conditions>
               <Setter TargetName="zzz" Property="Background" Value="#D6D4D4" />
           </MultiTrigger>           
       </ControlTemplate.Triggers>
   </ControlTemplate>

This results in the correct highlight and select colors!
Tags
GridView
Asked by
Bart Reekmans
Top achievements
Rank 1
Answers by
Bart Reekmans
Top achievements
Rank 1
Dimitrina
Telerik team
Vanya Pavlova
Telerik team
Share this question
or