Hi,
I want to create special rows that have only one column (i.e. column span for a specific row).
So I created ControlTemplate with that single column, created a Style that change the template property to the new template and created RowStyleSelector that uses that template when needed. That worked but created a row that doesn't have the IndicatorPresenter at the start of the row.
You can see the picture..
Can I merge cells at the grid and stay with the default template?
Or how can I make sure that the IndicatorPresenter will appear with the same styles.
3 Answers, 1 is accepted
May you please share with us the style you are currently using? You may take a look at the default template of GridViewRow and to see how the IndicatorPresenter is incorporated there:
<
Border
x:Name
=
"PART_IndicatorPresenter"
BorderBrush
=
"{StaticResource ControlOuterBorder}"
BorderThickness
=
"0,0,1,1"
Grid.Column
=
"0"
Grid.RowSpan
=
"3"
telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
Visibility
=
"{TemplateBinding RowIndicatorVisibility}"
VerticalAlignment
=
"Stretch"
Width
=
"25"
>
....
</
Border
>
On the other hand if you do not need to use the RowIndicator just set the RowIndicatorVisibility property of RadGridView to Collapsed. Feel free to submit a new support ticket where we can see what might be possible in your custom layout. Thus we would be able to provide you with an appropriate solution.
I look forward to hearing from you!
Kind regards,
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Hi Vanya,
This is the xaml:
<Grid.Resources>
<ControlTemplate x:Key="SpacialRowTemplate" TargetType="telerik:GridViewRow">
<StackPanel Orientation="Horizontal">
<Border x:Name="PART_IndicatorPresenter" Width="25" VerticalAlignment="Stretch" BorderThickness="0,0,1,0" Visibility="Visible"/>
<TextBox Text="{Binding Name, Mode=OneWay}" IsReadOnly="False"/>
</StackPanel>
</ControlTemplate>
<local:RowSelector x:Key="RowSelector">
<local:RowSelector.SpacialRowStyle>
<Style TargetType="telerik:GridViewRow">
<Setter Property="Template" Value="{StaticResource SpacialRowTemplate}" />
</Style>
</local:RowSelector.SpacialRowStyle >
<local:RowSelector.RegularRowStyle>
<Style TargetType="telerik:GridViewRow" />
</local:RowSelector.RegularRowStyle>
</local:RowSelector >
</Grid.Resources>
<telerik:RadTreeListView x:Uid="TelerikTreeList" x:Name="TelerikTreeList" Margin="0"
… RowStyleSelector="{StaticResource StepsRowSelector}" >
And this is the selector code:
public class RowSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
if (item is StData)
{
StData stData = item as StData;
if (stData.IsSpacial)
{
return SpacialRowStyle;
}
else
{
return RegularRowStyle;
}
}
return null;
}
public Style SpacialRowStyle { get; set; }
public Style RegularRowStyle { get; set; }
}
I don’t have the BorderBrush
brush, guessing that this is the problem, but the behavior that the small arrow will be painted when the row is selected is missing too.
I think that maybe providing a new template is not the best solution. Could there be another solution using a different approach?
Thank you for sharing this snippet with us! You have created a completely new row layout for RadGridView.
Within custom defined RowLayout for your RadGridView you should define your own triggers for these GridViewRows in a similar way as it is implemented in a default template of a GridViewRow. Indeed you are building everything from scratch.
In your particular case you should implement the following behavior:
<
Style
x:Key
=
"GridViewRowStyle1"
TargetType
=
"{x:Type telerik:GridViewRow}"
>
<
Setter
Property
=
"Background"
Value
=
"White"
/>
<
Setter
Property
=
"IsTabStop"
Value
=
"False"
/>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:GridViewRow}"
>
<
Border
BorderBrush
=
"{TemplateBinding BorderBrush}"
BorderThickness
=
"{TemplateBinding BorderThickness}"
>
<
Grid
Background
=
"{TemplateBinding Background}"
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"25"
/>
<
ColumnDefinition
/>
</
Grid.ColumnDefinitions
>
<
Border
x:Name
=
"PART_IndicatorPresenter"
BorderBrush
=
"#FF848484"
BorderThickness
=
"0,0,1,1"
Grid.Column
=
"0"
Grid.RowSpan
=
"3"
telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation
=
"Vertical"
Visibility
=
"{TemplateBinding RowIndicatorVisibility}"
VerticalAlignment
=
"Stretch"
Width
=
"25"
>
<
Grid
x:Name
=
"NavigatorIndicator"
HorizontalAlignment
=
"Center"
Height
=
"11"
Visibility
=
"Collapsed"
VerticalAlignment
=
"Center"
Width
=
"11"
>
<
Path
Data
=
"F1M32.0234,6.66669L24.2923,0.0248413 28.3697,0.0248413 32,3.14362 36.1492,6.70819 32,10.2728 28.4664,13.3085 24.2923,13.3085 32.0234,6.66669z"
Fill
=
"#FF848484"
HorizontalAlignment
=
"Center"
Height
=
"8"
Margin
=
"0"
Stretch
=
"Fill"
VerticalAlignment
=
"Center"
Width
=
"8"
/>
</
Grid
>
</
Border
>
<
TextBox
Grid.Column
=
"1"
telerik:StyleManager.Theme
=
"Office_Black"
Margin
=
"1,0,0,1"
Text
=
"{Binding Property1, Mode=OneWay}"
IsReadOnly
=
"False"
/>
</
Grid
>
</
Border
>
<
ControlTemplate.Triggers
>
<
MultiTrigger
>
<
MultiTrigger.Conditions
>
<
Condition
Property
=
"IsSelected"
Value
=
"True"
/>
<
Condition
Property
=
"DisplayVisualCues"
Value
=
"True"
/>
</
MultiTrigger.Conditions
>
<
Setter
Property
=
"Visibility"
TargetName
=
"NavigatorIndicator"
Value
=
"Visible"
/>
</
MultiTrigger
>
</
ControlTemplate.Triggers
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
</
Window.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
DataContext
=
"{Binding Source={StaticResource SampleDataSource}}"
>
<
telerik:RadGridView
IsSynchronizedWithCurrentItem
=
"True"
RowStyle
=
"{StaticResource GridViewRowStyle1}"
ItemsSource
=
"{Binding Collection}"
/>
</
Grid
>
Please let me know how this works for you!
All the best,
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>