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
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)?
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 >>
<
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.
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?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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?
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 >>
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.
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.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
This was added to WPF in .NET 4?
I'm using framework 3.5
You may define your own Triggers for this ControlTemplate and manipulate the elements you need.
Please check MSDN for further reference.
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
<
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!