Welcome to the Xceed Community | Help
Community Search  
More Search Options

change highlight color in cell editor

Sort Posts: Previous Next
  •  09-25-2011, 9:37 PM Post no. 31087

    change highlight color in cell editor

    how do i do this?

     ive tried to change it in the CellEditor style but the property does not exist. I am assuming hasto do with textbox property

     

    <Style x:Key="shipperCellEditorStyle" TargetType="sldg:TextCellEditor"

    BasedOn="{StaticResource SignatureThemeCellEditoStyle}">

    <Setter Property="SelectionBackground" Value="Color" />

    </Style>

  •  09-27-2011, 2:49 PM Post no. 31099 in reply to 31087

    Re: change highlight color in cell editor

    If you want to modify the color of the selected text within your editing TextBox, you need to modify the ControlTemplate since there are no existing property on the TextCellEditor that are directly mapped to the underling TextBox.

    Also, since your are styling the "TextCellEditor" your style should be based on "SignatureThemeTextCellEditorStyle" instead of "SignatureThemeCellEditoStyle".

    To  modify the ControlTemplate, you can simply copy it from the theme xaml files installed within the "Theme" folder of your installation directory. (Ex. "C:\Program Files (x86)\Xceed\Xceed DataGrid for Silverlight v1.3\Themes\Blend")

    Pick the appropriate xaml file for the theme you are using. In this case "SignatureThemeExplicitStyles.xaml"

    Paste the ControlTemplate in your code and modify the appropriately. In this case, you set the "SelectionBackground" to the desired value. Here is the resulting xaml that you should be using in you code:

    <Style x:Key="myCellEditorStyle" TargetType="sldg:TextCellEditor"

                      BasedOn="{StaticResource SignatureThemeTextCellEditorStyle}">

                         <Setter Property="Template">

                            <Setter.Value>

                               <ControlTemplate TargetType="sldg:TextCellEditor">

                                  <sldg:AutoSelectTextBox x:Name="TextHost"

                                                          SelectionBackground="Orange"

                                                          Padding="2"

                                                          CaretBrush="White"

                                                          AcceptsReturn="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=AcceptsReturn}"

                                                          HorizontalAlignment="Stretch"

                                                          VerticalAlignment="Stretch"

                                                          AutoSelectBehavior="OnFocus"

                                                          Background="{TemplateBinding Background}"

                                                          BorderThickness="{TemplateBinding BorderThickness}"

                                                          BorderBrush="{TemplateBinding BorderBrush}"

                                                          Foreground="{StaticResource SignatureThemeForegroundBrush}"

                                                          Template="{StaticResource SignatureThemeCellEditorTextBoxTemplate}" />                             

                               </ControlTemplate>

                            </Setter.Value>

                         </Setter>

                      </Style>

     

    But... if you want a pro-tip, as you check your theme file, you can observe that the AutoSelectTextBox is only used by the ControlTemplate of the TextCellEditor. In this case, you could safely create an implicit style on "AutoSelectTextBox" and set the SelectionBackground value without affecting the look of anything else. For columns with numbers, use the "NumericTextBox" type. The resulting overrides could then be simplified to this:

                       <Style TargetType="sldg:AutoSelectTextBox">

                          <Setter Property="SelectionBackground" Value="Orange"/>

                      </Style>

     

                      <Style TargetType="sldg:NumericTextBox">

                         <Setter Property="SelectionBackground" Value="Orange"/>

                      </Style>

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.