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
320
TextTrimming on XamTextEditor
posted

Hi everybody.

 

I'm trying to make the text appear trimmed with ellipsis in text fields.

Adding the following style ao app / page / grid resources had no effect:

<Style TargetType="{x:Type igEditors:XamTextEditor}">
   <Setter Property="HorizontalContentAlignment" Value="Stretch" />
   <Setter Property="TextBlock.TextTrimming" Value="CharacterEllipsis" />
</Style>

 

Does anyone know how ti achieve it?

 

Many thanks,

Yaakov

Parents
No Data
Reply
  • 320
    Verified Answer
    posted

     OK, found a solution:

     <Style TargetType="{x:Type igEditors:XamTextEditor}">
       <Setter Property="HorizontalContentAlignment" Value="Stretch" />

     <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type igEditors:XamTextEditor}">
                        <Border x:Name="MainBorder"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                             >
                            <!-- SSP 10/3/07 BR25672 Took the following code out of Border element above since
                                        the TextBlock below is already setting that value. We don't want to substract
                                        the padding twice.
                                Margin="{TemplateBinding Padding}"-->
                            <TextBlock x:Name="TextBlock"
                                Margin="{TemplateBinding Padding}"
                                Text="{TemplateBinding DisplayText}"
                                TextWrapping="{TemplateBinding TextWrapping}"

                                TextTrimming="CharchterEllipsis"

                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                TextAlignment="{TemplateBinding TextAlignmentResolved}"
                              />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsEmbedded" Value="False">
                                <Setter TargetName="MainBorder" Property="CornerRadius" Value="1" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
    </Style>

     The template was taken from "C:\Program Files\Infragistics\NetAdvantage for WPF (Express) 2008 Vol. 2\DefaultStyles\Editors\EditorsGeneric_Express.xaml".

Children