Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1735
How to change the SelectedBrush of the XamNumericEditor
posted

We are trying to do some changes to the style of the XamNumericEditor. Our style is similar to the Office2013 style, so we start with it.

From what I have observed the style of the XamNumericEditor is based of the XamMaskedEditor:

<Style TargetType="{x:Type igEditors:XamNumericEditor}" BasedOn="{StaticResource {x:Type igEditors:XamMaskedEditor}}" />

<Style TargetType="{x:Type igEditors:XamMaskedEditor}" x:Key="XamMaskedEditorBaseStyle">

!-- ********************************* Rest of the Style here ********************************* -->

So we follow the steps of Infragistics Styles, so our changes are consistent, however, I can't find how to change the highlight color of the selected text (the equivalent of SelectionBrush on a TextBox).

Apparently the MaskedEditor uses a SectionsList to show the number and mask it, but I can't find how you are setting the selected background text:

<Style x:Key="SectionsListStyle" TargetType="{x:Type igEditors:SectionsList}">

<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:SectionsList}">
<ScrollViewer Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
<StackPanel IsItemsHost="True" Orientation="Horizontal" />
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

And each item in turn is shown within a SectionPresenter:

<Style TargetType="{x:Type igEditors:SectionPresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:SectionPresenter}">
<igEditors:DisplayCharactersList
ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Section.DisplayChars, Mode=OneWay}"
/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

But I can't find any property that defines the highlight color of the selected text. How can I set it?

Thank you!

Parents
  • 138253
    Verified Answer
    Offline posted

    Hello,

    Thank you for your post. I have been looking into it and I can suggest you copy the default style for the DisplayCharacterPresenter element and change the Fill of the Rectangle(SelectionRect) inside its Template. The default Styles for the Editors are located here by default:

    C:\Program Files (x86)\Infragistics\2014.1\WPF\DefaultStyles\Editors\EditorsGeneric.xaml file

    Also here is a code snippet you can use:

    <igEditors:XamNumericEditor VerticalAlignment="Top">
     <igEditors:XamNumericEditor.Resources>
      <igWindows:BoolToHiddenConverter x:Key="BoolToHidden" />
      <Style TargetType="{x:Type igEditors:DisplayCharacterPresenter}">
       <Setter Property="Template">
        <Setter.Value>
         <ControlTemplate TargetType="{x:Type igEditors:DisplayCharacterPresenter}">
          <Grid>
           <TextBlock
         x:Name="TextBlock"
         Margin="0,0,0,0"
         Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisplayCharacter.DrawString, Mode=OneWay}"
         Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisplayCharacter.Visibility, Mode=OneWay}" />
           <Rectangle x:Name="SelectionRect" Margin="0,0,0,0" Fill="PeachPuff" Opacity="0.5"
           Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DrawAsSelected, Mode=OneWay, Converter={StaticResource BoolToHidden} }"
           IsHitTestVisible="False"
           />
          </Grid>
         </ControlTemplate>
        </Setter.Value>
       </Setter>
      </Style>
     </igEditors:XamNumericEditor.Resources>
    </igEditors:XamNumericEditor>

    Please let me know if you have further question on this matter.

    Looking forward for your reply

Reply Children
No Data