Concatenated Text in TextBlock DataTrigger
Asked Answered
U

1

0

I try to work with a concatenated text in the setter of a textblock.

textblock looks like that:

<TextBlock>
    <Run Text="{x:Static languages:visuTexts.Lenght}" />
    <Run Text="A [LA]"/>
    <TextBlock.Style>
        <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Product.DiameterA}" Value="0">
                    <Setter Property="Text" Value="concatenated text here" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>

i want to change Length A [LA] to Length [L] depending on the value of Produkt.DiameterA

Ushas answered 2/2, 2017 at 10:30 Comment(0)
G
2

Use a Style for the Run element:

<TextBlock>
    <Run Text="{x:Static languages:visuTexts.Lenght}" />
    <Run>
        <Run.Style>
            <Style TargetType="Run">
                <Setter Property="Text" Value="A [LA]" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Product.DiameterA}" Value="0">
                            <Setter Property="Text" Value="[L]" />
                        </DataTrigger>
                    </Style.Triggers>
            </Style>
        </Run.Style>
    </Run>
</TextBlock>
Granite answered 2/2, 2017 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.