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

Highlight search doesn't work with rowstyle

1 Answer 212 Views
GridView
This is a migrated thread and some comments may be shown as answers.
alexandre
Top achievements
Rank 1
alexandre asked on 19 Jul 2017, 12:34 PM

Hi,

I'im trying to create a row style for a specific need.

I was starting from a sample found on this forum called "custom row layout"

What i want is to be able to use the search panel and then show highlight.

here is the xaml code :

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="_42060_CustomRowLayout.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
<Style x:Key="MyCustomRowStyle" TargetType="{x:Type telerik:GridViewRow}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type telerik:GridViewRow}">
<Border x:Name="rowsContainer" Background="#FF525252" Padding="8,8,8,0">
                    <Border Background="Transparent" x:Name="selectedRow"
                        BorderThickness="1" BorderBrush="#FF000000">
  
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />                                
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
  
                            <TextBlock Text="Code:"
                                       Grid.Column="0" Grid.Row="0"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
                            <telerik:HighlightTextBlock Text="{Binding CD}"
                                       Grid.Column="1" Grid.Row="0"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
                              
                            <TextBlock Text="Description:"
                                       Grid.Column="0" Grid.Row="1"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
                            <TextBlock Text="{Binding DESC}"  
                                       Grid.Column="1" Grid.Row="1"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
                              
                            <TextBlock Text="Enabled:"
                                       Grid.Column="0" Grid.Row="2"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
  
                            <TextBlock Text="{Binding ENABLED}"
                                       Grid.Column="1" Grid.Row="2"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
  
                        </Grid>
                    </Border>
                </Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="White"/>
<Setter Property="BorderBrush" Value="#FFCBCBCB"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
            
</Style>
</Window.Resources>

<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}">
<telerik:RadGridView Margin="293,8,8,8" AutoGenerateColumns="False" RowStyle="{DynamicResource MyCustomRowStyle}" DataContext="{Binding SelectedItems, ElementName=radGridView}" ItemsSource="{Binding}" ShowSearchPanel="True"/>
        <telerik:RadGridView x:Name="radGridView" HorizontalAlignment="Left" Margin="0,8" ItemsSource="{Binding Collection}" Width="289" AutoGenerateColumns="False" ShowSearchPanel="True">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Artist}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Year}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</Window>

 

could you help me ?

regards,

Alex

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
1
Dinko | Tech Support Engineer
Telerik team
answered on 24 Jul 2017, 12:17 PM
Hello ,

Thank you for contacting us.

Highlight text in the GridView is not supported when a custom style is applied to the RowStyle property of the grid. As an approach which you can try is to use the ApplyHighlighting() method of the HighlightTextBlock class. Currently, this method is Private so you can use a reflection in order to get the method and called it for the HighlightTextBlock

I have prepared a sample project which demonstrates this approach. 

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
alexandre
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or