Telerik Forums
UI for WPF Forum
1 answer
91 views

Hello.

I'm working on changing from noxaml to xaml.
There was a problem while working.

The source below is imported to customize the Template of RadGridView GridViewSearchPanel.
<Style TargetType="telerik:GridViewSearchPanel">
	<Setter Property="Template">
		<Setter.Value>
			<ControlTemplate TargetType="telerik:GridViewSearchPanel">
				<Border BorderThickness="0" Background="AliceBlue" BorderBrush="Transparent">
					<Grid UseLayoutRounding="True">
						<Grid.ColumnDefinitions>
							<ColumnDefinition/>
							<ColumnDefinition Width="Auto"/>
						</Grid.ColumnDefinitions>
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="Auto"/>
							</Grid.ColumnDefinitions>
							<TextBlock	telerik:LocalizationManager.ResourceKey="GridViewSearchPanelTopText"
													TextWrapping="Wrap"
													Margin="{TemplateBinding Padding}"
													HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
													VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
													IsHitTestVisible="False"/>
							<Grid Grid.Column="1" Margin="10 0" VerticalAlignment="Center">
								<TextBox x:Name="PART_SearchAsYouTypeTextBox"
													AutomationProperties.Name="search as you type textBox"
													Text="{Binding SearchText, Mode=TwoWay}"
													MinWidth="160"
													MaxWidth="200"
													Padding="5 3 15 3"
													telerik:TextBoxBehavior.UpdateTextOnEnter="True"
													IsTabStop="{TemplateBinding IsTabStop}"
													FontSize="{TemplateBinding FontSize}"
													FontFamily="{TemplateBinding FontFamily}"
													MinHeight="28"/>
								<telerik:RadButton	IsTabStop="False" Visibility="Visible"
											Style="{StaticResource ClearSearchValueButtonStyle}"
											Command="searchPanel:GridViewSearchPanelCommands.ClearSearchValue"/>
							</Grid>
						</Grid>

					</Grid>
				</Border>
			</ControlTemplate>
		</Setter.Value>
	</Setter>
</Style>

The method I know of is to take the style of noxaml as it is and redefine it.

<Style x:Key="ClearSearchValueButtonStyle" TargetType="telerik:RadButton">
        <Setter Property="Template" Value="{StaticResource ClearSearchValueButtonTemplate}"/>
        <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=IconBrush}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Width" Value="28"/>
        <Setter Property="Height" Value="28"/>
        <Setter Property="HorizontalAlignment" Value="Right"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=AccentMouseOverBrush}"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Foreground" Value="{telerik1:FluentResource ResourceKey=AccentPressedBrush}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

If other styles are not defined, will they be applied automatically?

The style was applied as 'Setting Application-Wide Built-in Theme in the Code-Behind'.

 

Also, Is there a way to override Style 'x:key="SearchPanel" TargetType="telerik:GridViewSearchPanel"' and apply it to <telerik:RadGridView> as a key value?

If you create and define multiple gridviews in one xaml, they are all applied. I want to apply only one.

 

Thanks.

Dilyan Traykov
Telerik team
 answered on 22 Jul 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?