2017-02-02 99 views
0

我嘗試使用文本塊的setter中的連接文本。TextBlock DataTrigger中的連接文本

文本塊的樣子說:

<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> 

我想這取決於Produkt.DiameterA

回答

0

值使用樣式的運行元件來變更Length A [LA]Length [L]

<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>