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

How to change the Foreground of the searchtextbox of PropertyGrid

3 Answers 46 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Imran
Top achievements
Rank 1
Imran asked on 09 Jul 2014, 05:22 PM
Hi team,

Could you please advise, How can I change the searchtextbox's foreground property of the propertyGrid either through Xaml or Code?

Regards,
Imran

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 10 Jul 2014, 08:54 AM
Hello,

In order to achieve your goal, you can predefine RadPropertyGrid's template and change the Foreground proeprty of the TextBox named - "searchAsYouTypeTextBox":
             .
             .
             .
<ControlTemplate x:Key="RadPropertyGridTemplate" TargetType="controls:RadPropertyGrid">
        <Border x:Name="PART_RootElement" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
            <Grid x:Name="PART_PropertyGridContainer" Background="{TemplateBinding Background}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Border x:Name="Header"
                        BorderBrush="{StaticResource ControlOuterBorder}"
                        MinHeight="28"
                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HeaderVisibilityConverter}}"
                        Margin="0, 0, 0, 2"
                        BorderThickness="0,0,0,1">
                    <Border BorderBrush="{StaticResource ControlInnerBorder}" BorderThickness="1" Background="{StaticResource PropertyGrid_HeaderBackground}">
                        <Grid Margin="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <telerik:RadRadioButton x:Name="groupButton"
                                    Visibility="{TemplateBinding SortAndGroupButtonsVisibility}"
                                    Margin="0,0,3,0"
                                    Width="28"
                                    IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsGrouped, Mode=TwoWay}">
                                <ToolTipService.ToolTip>
                                    <ToolTip telerik:LocalizationManager.ResourceKey="Categorize"/>
                                </ToolTipService.ToolTip>
                                <Path
                                        Data="M7.0000019,8.9999981 L16.999998,8.9999981 L16.999998,9.9999981 L7.0000019,9.9999981 z M7.0000019,6.9999995 L16.999998,6.9999995 L16.999998,7.9999995 L7.0000019,7.9999995 z M0,6 L3.9999998,8.5 L0,11 z M6.999999,3.0000055 L16.999996,3.0000055 L16.999996,4.0000052 L6.999999,4.0000052 z M7.0000019,0.99999905 L16.999998,0.99999905 L16.999998,1.9999989 L7.0000019,1.9999989 z M0,0 L4,2.5000002 L0,5.0000005 z"
                                        Fill="{StaticResource RadioButton_Indicator}"
                                        Height="11"
                                        Stretch="Fill"
                                        StrokeThickness="0"
                                        Width="17"/>
                            </telerik:RadRadioButton>
                            <telerik:RadRadioButton x:Name="sortButton" Content="A-Z" Grid.Column="1" Visibility="{TemplateBinding SortAndGroupButtonsVisibility}" Width="28">
                                <ToolTipService.ToolTip>
                                    <ToolTip telerik:LocalizationManager.ResourceKey="Alphabetical"/>
                                </ToolTipService.ToolTip>
                            </telerik:RadRadioButton>
                            <TextBox x:Name="searchAsYouTypeTextBox"
                                    Visibility="{TemplateBinding SearchBoxVisibility}"
                                    Grid.Column="2"
                                    HorizontalAlignment="Stretch"
                                    Margin="2,0,0,0"
                                    telerik:TextBoxBehavior.SelectAllOnGotFocus="True"
                                    Text="{Binding FilterText, ElementName=PropertyGridPresenter, Mode=TwoWay}"
                                    telerik:TextBoxBehavior.UpdateTextOnEnter="True"
                                    telerik:TextBoxBehavior.UpdateTextOnTextChanged="True"/>
                     .
                     .
                     .

The other option is to subscribe to PropertyGrid's Loaded event find the TextBox using our ChildrenOfType<> extension method:
private void RadPropertyGrid_Loaded(object sender, RoutedEventArgs e)
        {
            var searchAsYouTypeTextBox = (sender as RadPropertyGrid).ChildrenOfType<TextBox>().FirstOrDefault(t => t.Name == "searchAsYouTypeTextBox");
 
            searchAsYouTypeTextBox.Foreground = new SolidColorBrush(Colors.Red);
        }

I hope this helps.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Imran
Top achievements
Rank 1
answered on 18 Jul 2014, 10:51 AM
Thanks Yoan !! It was Really helpful.

Could ou please address my post regarding "Aligning of properties..."
0
Yoan
Telerik team
answered on 21 Jul 2014, 04:37 PM
Hi Imran,

I am glad to hear this. I have already answered your other forum thread.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
PropertyGrid
Asked by
Imran
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Imran
Top achievements
Rank 1
Share this question
or