How to change the Foreground of the searchtextbox of PropertyGrid

4 posts, 0 answers
  1. Imran
    Imran avatar
    10 posts
    Member since:
    May 2014

    Posted 09 Jul 2014 Link to this post

    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
  2. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 10 Jul 2014 Link to this post

    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.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Imran
    Imran avatar
    10 posts
    Member since:
    May 2014

    Posted 18 Jul 2014 in reply to Yoan Link to this post

    Thanks Yoan !! It was Really helpful.

    Could ou please address my post regarding "Aligning of properties..."
  5. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 21 Jul 2014 Link to this post

    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.
     
Back to Top