Multiple launch items in WPF Style setter

Is it possible to XAMLdefine a few Runinside the installer Style?

The following are two Runand are not executed:

The Value property is set more than once.

<TextBlock>
    <TextBlock.Style>
         <Style TargetType="{x:Type TextBlock}">
              <Setter Property="Text">
                   <Setter.Value>
                       <Run Text="{Binding SelectedItem.iso}"/>
                       <Run Text="{Binding SelectedItem.value}"/>
                  </Setter.Value>
              </Setter>
             <Style.Triggers>
                 <DataTrigger Binding="{Binding SelectedItem.type}" Value={x:Null}">
                      <Setter Property="Text" Value="No value" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </TextBlock.Style>
</TextBlock>

Could this be fixed while keeping using multiple Run?

+4
source share
1 answer

The setter works with one property, so it can have only one value, the error you get is logical: it has no way to understand what you are trying to do, it can just ... set the property for the given value.

, , , : . MultiBinding, , StringFormat :

<Setter.Value>
    <MultiBinding StringFormat="{}{0}{1}{2}"><!-- Format as you wish -->
        <Binding Path="SelectedItem.iso"/>
        <Binding Source="{x:Static System:Environment.NewLine}"/>
        <Binding Path="SelectedItem.value"/>
    </MultiBinding>
</Setter.Value>

StringFormat: {} , , .

+2

All Articles