What do I do wrong?
9 Answers, 1 is accepted
Could you please send us the XAML code that you have used.
Best wishes,
Milan
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
This is the GridView
<telerikGridView:RadGridView
x:Name="TradingGridCard"
CanUserFreezeColumns="False"
AutoGenerateColumns="false"
ShowGroupPanel="False"
RowIndicatorVisibility="Collapsed"
ItemsSource="{Binding}"
IsFilteringAllowed="False"
Background="{x:Null}"
Margin="0"
RowStyle="{DynamicResource CardViewRowStyle}"
ColumnsWidthMode="Fill"
Visibility="Collapsed"
SelectionMode="Single"
Grid.Row="1">
<telerikGridView:RadGridView.Columns>
<telerikGridView:GridViewDataColumn
DataMemberBinding="{Binding Side}"
Header="Side" />
<telerikGridView:GridViewDataColumn
DataMemberBinding="{Binding Ticker}"
Header="Name" />
<telerikGridView:GridViewDataColumn
DataMemberBinding="{Binding Price}"
Header="Price" />
<telerikGridView:GridViewDataColumn
DataMemberBinding="{Binding Tick}"
Header="Change" />
</telerikGridView:RadGridView.Columns>
</telerikGridView:RadGridView>
And here is the style:
<Style
x:Key="CardViewRowStyle"
TargetType="{x:Type telerik:GridViewRow}">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type telerik:GridViewRow}">
<ControlTemplate.Resources>
<Storyboard
x:Key="Load">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="rowsContainer"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="100" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.5000000"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Border
x:Name="rowsContainer"
Padding="0"
RenderTransformOrigin="0.5,0.5"
Margin="2"
CornerRadius="4"
BorderThickness="1"
Background="{DynamicResource CardBG}"
HorizontalAlignment="Stretch"
BorderBrush="Black">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Border.RenderTransform>
<Border
Background="{x:Null}"
x:Name="selectedRow"
BorderThickness="1"
BorderBrush="{x:Null}"
Margin="-1">
<Grid
Width="Auto"
MinWidth="150">
<Rectangle
Margin="0"
RadiusY="3"
RadiusX="3"
Opacity="1"
Fill="{Binding TickColor}"
RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<TransformGroup>
<RotateTransform
Angle="{Binding TickAngle}" />
</TransformGroup>
</Rectangle.RenderTransform>
<Rectangle.OpacityMask>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="#66000000"
Offset="0" />
<GradientStop
Color="#00000000"
Offset="1" />
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
<Path
Data="M20,5.9608237E-06 L40,17.475647 19.998252,34.423077 0,17.475647 z"
Fill="{Binding TickColor}"
Margin="4,5,5,5"
Stretch="Fill"
UseLayoutRounding="False"
Height="Auto"
Opacity="1"
VerticalAlignment="Stretch"
Width="Auto"
RenderTransformOrigin="0.5,0.5"
OpacityMask="{DynamicResource TickOpacityMack}"
Stroke="{DynamicResource TickStroke}">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform
Angle="{Binding TickAngle}" />
</TransformGroup>
</Path.RenderTransform>
</Path>
<Path
Data="M4.1666668,4.7499998 L18.805,4.7499998 18.68,39.501741 4.5833334,39.501741 C1.375,39.49974 -3.6380794E-07,38.054827 5.6843419E-14,35.293402 L5.6843419E-14,8.9166724 C0.041666667,7.0833158 0.87500001,4.75 4.1666668,4.7499998 z"
HorizontalAlignment="Left"
Margin="2,2,0,2"
Stretch="Fill"
Width="20"
VerticalAlignment="Stretch"
Height="Auto"
Opacity="1"
Fill="#FF01019F"
Grid.RowSpan="2"
Visibility="Collapsed">
<Path.OpacityMask>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="Black"
Offset="0.75" />
<GradientStop
Color="#99FFFFFF"
Offset="1" />
<GradientStop
Color="#99FFFFFF" />
<GradientStop
Color="Black"
Offset="0.25" />
</LinearGradientBrush>
</Path.OpacityMask>
</Path>
<StackPanel
Orientation="Horizontal"
d:LayoutOverrides="Height"
Margin="5,2">
<Grid
HorizontalAlignment="Left"
Height="46"
Width="20"
Visibility="Collapsed">
<Rectangle
Fill="#FF010168"
RadiusX="4"
RadiusY="4"
HorizontalAlignment="Stretch"
Margin="0"
Width="Auto"
Height="Auto">
<Rectangle.OpacityMask>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="Black" />
<GradientStop
Color="#00000000"
Offset="1" />
</LinearGradientBrush>
</Rectangle.OpacityMask>
</Rectangle>
<telerik:GridViewCell
BorderThickness="0"
Value="{Binding Side}"
Margin="0"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Content="B"
Grid.Row="0"
BorderBrush="{x:Null}"
FontSize="18.667"
FontWeight="Normal"
Foreground="White"
Grid.RowSpan="1"
d:LayoutOverrides="Width" />
</Grid>
<Grid
Margin="0"
VerticalAlignment="Center"
Height="50">
<Grid.RowDefinitions>
<RowDefinition
Height="0.7*" />
<RowDefinition
Height="0.3*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="70" />
<ColumnDefinition
Width="56.75" />
<ColumnDefinition
Width="*" />
</Grid.ColumnDefinitions>
<telerik:GridViewCell
BorderThickness="0"
Foreground="{DynamicResource CardForeground}"
Value="{Binding Ticker}"
Margin="0"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Content="Ticker"
Grid.Row="0"
Background="{x:Null}"
BorderBrush="{x:Null}"
d:LayoutOverrides="Width"
Grid.ColumnSpan="1"
FontSize="18.667"
Grid.Column="0"
FontWeight="Bold" />
<telerik:GridViewCell
BorderThickness="0"
Foreground="{DynamicResource CardForeground}"
Value="{Binding Price}"
Margin="0"
VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Content="Price"
Grid.Row="0"
Background="{x:Null}"
BorderBrush="{x:Null}"
d:LayoutOverrides="Width"
Grid.Column="1"
FontSize="16" />
<telerik:GridViewCell
BorderThickness="0"
Value="{Binding Tick}"
Margin="0"
VerticalAlignment="Center"
HorizontalAlignment="Left"
Content="Tick"
Background="{x:Null}"
BorderBrush="{x:Null}"
FontSize="16"
Foreground="{Binding TickColor}"
Grid.Column="2" />
<StackPanel
Grid.Column="3"
HorizontalAlignment="Left"
Orientation="Vertical"
Width="Auto"
d:LayoutOverrides="Height"
Grid.RowSpan="2"
Margin="3.25,8,0,0"
Visibility="Collapsed">
<Path
Data="M20,0 L40,20 19.998252,16.008226 0,20 z"
Fill="#FF005C0D"
Margin="0"
Stretch="Fill"
UseLayoutRounding="False"
Height="16"
VerticalAlignment="Top"
Width="12"
Stroke="#FF3BFF00"
Opacity="0.515"
Visibility="Visible" />
</StackPanel>
<TextBlock
Margin="5,0,0,0"
TextWrapping="Wrap"
Text="193.82 x 193.44 7 x 2"
d:LayoutOverrides="Width, Height"
Grid.Row="1"
Foreground="White"
Grid.ColumnSpan="3"
Grid.Column="0" />
<Rectangle
Grid.ColumnSpan="4"
Fill="#FF003793"
Height="1"
Margin="5,0"
VerticalAlignment="Bottom"
Visibility="Collapsed" />
</Grid>
</StackPanel>
<Rectangle
Margin="0,0,0,20"
RadiusY="4"
RadiusX="4"
Visibility="Collapsed">
<Rectangle.Fill>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="#19FFFFFF"
Offset="0" />
<GradientStop
Color="#4CFFFFFF"
Offset="1" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Grid>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I tried removing most of the style code, it shortening it to:
<Style
x:Key="CardViewRowStyle"
TargetType="{x:Type telerik:GridViewRow}">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="{x:Type telerik:GridViewRow}">
<ControlTemplate.Resources>
<Storyboard
x:Key="Load">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="rowsContainer"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="100" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.5000000"
Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Border
x:Name="rowsContainer"
Padding="0"
RenderTransformOrigin="0.5,0.5"
Margin="2"
CornerRadius="4"
BorderThickness="1"
Background="{DynamicResource CardBG}"
HorizontalAlignment="Stretch"
BorderBrush="Black">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Border.RenderTransform>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
It still would not work
Thanks for your help
Nick
Let me use the correct format for the code.
Here is the GridView XAML code:
<telerikGridView:RadGridView |
x:Name="TradingGridCard" |
CanUserFreezeColumns="False" |
AutoGenerateColumns="false" |
ShowGroupPanel="False" |
RowIndicatorVisibility="Collapsed" |
ItemsSource="{Binding}" |
IsFilteringAllowed="False" |
Background="{x:Null}" |
Margin="0" |
RowStyle="{DynamicResource CardViewRowStyle}" |
ColumnsWidthMode="Fill" |
Visibility="Collapsed" |
SelectionMode="Single" |
Grid.Row="1"> |
<telerikGridView:RadGridView.Columns> |
<telerikGridView:GridViewDataColumn |
DataMemberBinding="{Binding Side}" |
Header="Side" /> |
<telerikGridView:GridViewDataColumn |
DataMemberBinding="{Binding Ticker}" |
Header="Name" /> |
<telerikGridView:GridViewDataColumn |
DataMemberBinding="{Binding Price}" |
Header="Price" /> |
<telerikGridView:GridViewDataColumn |
DataMemberBinding="{Binding Tick}" |
Header="Change" /> |
</telerikGridView:RadGridView.Columns> |
</telerikGridView:RadGridView> |
and Here is the CardViewRowStyle code
<Setter |
Property="Template"> |
<Setter.Value> |
<ControlTemplate |
TargetType="{x:Type telerik:GridViewRow}"> |
<ControlTemplate.Resources> |
<Storyboard |
x:Key="Load"> |
<DoubleAnimationUsingKeyFrames |
BeginTime="00:00:00" |
Storyboard.TargetName="rowsContainer" |
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"> |
<SplineDoubleKeyFrame |
KeyTime="00:00:00" |
Value="100" /> |
<SplineDoubleKeyFrame |
KeyTime="00:00:00.5000000" |
Value="0" /> |
</DoubleAnimationUsingKeyFrames> |
</Storyboard> |
</ControlTemplate.Resources> |
<Border |
x:Name="rowsContainer" |
Padding="0" |
RenderTransformOrigin="0.5,0.5" |
Margin="2" |
CornerRadius="4" |
BorderThickness="1" |
Background="{DynamicResource CardBG}" |
HorizontalAlignment="Stretch" |
BorderBrush="Black"> |
<Border.RenderTransform> |
<TransformGroup> |
<ScaleTransform /> |
<SkewTransform /> |
<RotateTransform /> |
<TranslateTransform /> |
</TransformGroup> |
</Border.RenderTransform> |
<Border |
Background="{x:Null}" |
x:Name="selectedRow" |
BorderThickness="1" |
BorderBrush="{x:Null}" |
Margin="-1"> |
<Grid |
Width="Auto" |
MinWidth="150"> |
<Rectangle |
Margin="0" |
RadiusY="3" |
RadiusX="3" |
Opacity="1" |
Fill="{Binding TickColor}" |
RenderTransformOrigin="0.5,0.5"> |
<Rectangle.RenderTransform> |
<TransformGroup> |
<RotateTransform |
Angle="{Binding TickAngle}" /> |
</TransformGroup> |
</Rectangle.RenderTransform> |
<Rectangle.OpacityMask> |
<LinearGradientBrush |
EndPoint="0.5,1" |
StartPoint="0.5,0"> |
<GradientStop |
Color="#66000000" |
Offset="0" /> |
<GradientStop |
Color="#00000000" |
Offset="1" /> |
</LinearGradientBrush> |
</Rectangle.OpacityMask> |
</Rectangle> |
<Path |
Data="M20,5.9608237E-06 L40,17.475647 19.998252,34.423077 0,17.475647 z" |
Fill="{Binding TickColor}" |
Margin="4,5,5,5" |
Stretch="Fill" |
UseLayoutRounding="False" |
Height="Auto" |
Opacity="1" |
VerticalAlignment="Stretch" |
Width="Auto" |
RenderTransformOrigin="0.5,0.5" |
OpacityMask="{DynamicResource TickOpacityMack}" |
Stroke="{DynamicResource TickStroke}"> |
<Path.RenderTransform> |
<TransformGroup> |
<RotateTransform |
Angle="{Binding TickAngle}" /> |
</TransformGroup> |
</Path.RenderTransform> |
</Path> |
<Path |
Data="M4.1666668,4.7499998 L18.805,4.7499998 18.68,39.501741 4.5833334,39.501741 C1.375,39.49974 -3.6380794E-07,38.054827 5.6843419E-14,35.293402 L5.6843419E-14,8.9166724 C0.041666667,7.0833158 0.87500001,4.75 4.1666668,4.7499998 z" |
HorizontalAlignment="Left" |
Margin="2,2,0,2" |
Stretch="Fill" |
Width="20" |
VerticalAlignment="Stretch" |
Height="Auto" |
Opacity="1" |
Fill="#FF01019F" |
Grid.RowSpan="2" |
Visibility="Collapsed"> |
<Path.OpacityMask> |
<LinearGradientBrush |
EndPoint="0.5,1" |
StartPoint="0.5,0"> |
<GradientStop |
Color="Black" |
Offset="0.75" /> |
<GradientStop |
Color="#99FFFFFF" |
Offset="1" /> |
<GradientStop |
Color="#99FFFFFF" /> |
<GradientStop |
Color="Black" |
Offset="0.25" /> |
</LinearGradientBrush> |
</Path.OpacityMask> |
</Path> |
<StackPanel |
Orientation="Horizontal" |
d:LayoutOverrides="Height" |
Margin="5,2"> |
<Grid |
HorizontalAlignment="Left" |
Height="46" |
Width="20" |
Visibility="Collapsed"> |
<Rectangle |
Fill="#FF010168" |
RadiusX="4" |
RadiusY="4" |
HorizontalAlignment="Stretch" |
Margin="0" |
Width="Auto" |
Height="Auto"> |
<Rectangle.OpacityMask> |
<LinearGradientBrush |
EndPoint="0.5,1" |
StartPoint="0.5,0"> |
<GradientStop |
Color="Black" /> |
<GradientStop |
Color="#00000000" |
Offset="1" /> |
</LinearGradientBrush> |
</Rectangle.OpacityMask> |
</Rectangle> |
<telerik:GridViewCell |
BorderThickness="0" |
Value="{Binding Side}" |
Margin="0" |
VerticalAlignment="Stretch" |
HorizontalAlignment="Stretch" |
Content="B" |
Grid.Row="0" |
BorderBrush="{x:Null}" |
FontSize="18.667" |
FontWeight="Normal" |
Foreground="White" |
Grid.RowSpan="1" |
d:LayoutOverrides="Width" /> |
</Grid> |
<Grid |
Margin="0" |
VerticalAlignment="Center" |
Height="50"> |
<Grid.RowDefinitions> |
<RowDefinition |
Height="0.7*" /> |
<RowDefinition |
Height="0.3*" /> |
</Grid.RowDefinitions> |
<Grid.ColumnDefinitions> |
<ColumnDefinition |
Width="70" /> |
<ColumnDefinition |
Width="56.75" /> |
<ColumnDefinition |
Width="*" /> |
</Grid.ColumnDefinitions> |
<telerik:GridViewCell |
BorderThickness="0" |
Foreground="{DynamicResource CardForeground}" |
Value="{Binding Ticker}" |
Margin="0" |
VerticalAlignment="Center" |
HorizontalAlignment="Stretch" |
Content="Ticker" |
Grid.Row="0" |
Background="{x:Null}" |
BorderBrush="{x:Null}" |
d:LayoutOverrides="Width" |
Grid.ColumnSpan="1" |
FontSize="18.667" |
Grid.Column="0" |
FontWeight="Bold" /> |
<telerik:GridViewCell |
BorderThickness="0" |
Foreground="{DynamicResource CardForeground}" |
Value="{Binding Price}" |
Margin="0" |
VerticalAlignment="Center" |
HorizontalAlignment="Stretch" |
Content="Price" |
Grid.Row="0" |
Background="{x:Null}" |
BorderBrush="{x:Null}" |
d:LayoutOverrides="Width" |
Grid.Column="1" |
FontSize="16" /> |
<telerik:GridViewCell |
BorderThickness="0" |
Value="{Binding Tick}" |
Margin="0" |
VerticalAlignment="Center" |
HorizontalAlignment="Left" |
Content="Tick" |
Background="{x:Null}" |
BorderBrush="{x:Null}" |
FontSize="16" |
Foreground="{Binding TickColor}" |
Grid.Column="2" /> |
<StackPanel |
Grid.Column="3" |
HorizontalAlignment="Left" |
Orientation="Vertical" |
Width="Auto" |
d:LayoutOverrides="Height" |
Grid.RowSpan="2" |
Margin="3.25,8,0,0" |
Visibility="Collapsed"> |
<Path |
Data="M20,0 L40,20 19.998252,16.008226 0,20 z" |
Fill="#FF005C0D" |
Margin="0" |
Stretch="Fill" |
UseLayoutRounding="False" |
Height="16" |
VerticalAlignment="Top" |
Width="12" |
Stroke="#FF3BFF00" |
Opacity="0.515" |
Visibility="Visible" /> |
</StackPanel> |
<TextBlock |
Margin="5,0,0,0" |
TextWrapping="Wrap" |
Text="193.82 x 193.44 7 x 2" |
d:LayoutOverrides="Width, Height" |
Grid.Row="1" |
Foreground="White" |
Grid.ColumnSpan="3" |
Grid.Column="0" /> |
<Rectangle |
Grid.ColumnSpan="4" |
Fill="#FF003793" |
Height="1" |
Margin="5,0" |
VerticalAlignment="Bottom" |
Visibility="Collapsed" /> |
</Grid> |
</StackPanel> |
<Rectangle |
Margin="0,0,0,20" |
RadiusY="4" |
RadiusX="4" |
Visibility="Collapsed"> |
<Rectangle.Fill> |
<LinearGradientBrush |
EndPoint="0.5,1" |
StartPoint="0.5,0"> |
<GradientStop |
Color="#19FFFFFF" |
Offset="0" /> |
<GradientStop |
Color="#4CFFFFFF" |
Offset="1" /> |
</LinearGradientBrush> |
</Rectangle.Fill> |
</Rectangle> |
</Grid> |
</Border> |
</Border> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
As long as I do not set RowStyle, I can select the rows within the grid.
If I set the RowStyle on a grid, I stop being able to do it.
I tried setting the Row Style to something very simple, e.g.:
<Style |
x:Key="CardViewRowStyle" |
TargetType="{x:Type telerik:GridViewRow}"> |
<Setter |
Property="Template"> |
<Setter.Value> |
<ControlTemplate |
TargetType="{x:Type telerik:GridViewRow}"> |
<Border |
x:Name="rowsContainer" |
Padding="0" |
RenderTransformOrigin="0.5,0.5" |
Margin="2" |
CornerRadius="4" |
BorderThickness="1" |
Background="{DynamicResource CardBG}" |
HorizontalAlignment="Stretch" |
BorderBrush="Black"> |
<Border.RenderTransform> |
<TransformGroup> |
<ScaleTransform /> |
<SkewTransform /> |
<RotateTransform /> |
<TranslateTransform /> |
</TransformGroup> |
</Border.RenderTransform> |
</Border> |
</ControlTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
Thanks for your help
It seems that the problem is caused by the missing resource CardBG. Once I replaced it with a simple Transparent brush the selection started working again.
Regards,
Milan
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
it is still not working in my case. Can you send me your code?
Thanks
Nick
Well since you have overwritten the default RowStyle you will not get the default selection indicators (like the orange background color) but nevertheless items will be selected. You could try subscribing to the SelectionChanged event and check if it is being fired whenever you slick on a row.
I have used the simple row style code in my test application. Just replace the "{DynamicResource CardBG}" with Red, for example.
I have also noticed that you have placed GridViewCell objects in the row template which is not recommended - you should be better of using simpler elements like TextBlock of TextBox.
Kind regards,
Milan
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Please tell me how to make it work in WPF.
thanks
Hi Nick Polyak,
This problem could only manifest if you are using an old version of RadGridView. Could you please upgrade to our latest WPF release (2009.3 1314).
Best wishes,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
thanks