c# – Path для MultiBinding

Question:

Is there a MultiBinding that returns an instance of a class, how can I refer to its field? Path="ObjectLink" does not work, because Path in MultiBinding missing

  <TextBlock Foreground="Red">
    <TextBlock.Style>
      <Style TargetType="{x:Type TextBlock}">
        <Setter Property="Text">
          <Setter.Value>
            <MultiBinding Path="ObjectLink" Converter="{StaticResource ResourceKey=m_GetObjectPropertyConverter}" StringFormat=' ({0})'>
              <Binding/>
              <Binding Source="{x:Static DataViewModels:PropertysViewModel.TypeSS}"/>
            </MultiBinding>
          </Setter.Value>
        </Setter>
      </Style>
    </TextBlock.Style>
  </TextBlock>

PS: the converter m_GetObjectPropertyConverter returns an instance of the class

Answer:

You can use double binding via Tag :

<Setter Property="Tag">
  <Setter.Value>
    <MultiBinding Converter="{StaticResource m_GetObjectPropertyConverter}">
      <Binding/>
      <Binding Source="{x:Static DataViewModels:PropertysViewModel.TypeSS}"/>
    </MultiBinding>
  </Setter.Value>
</Setter>
<Setter Property="Text"
        Value="{Binding Tag.ObjectLink, RelativeSource={RelativeSource Self}}"/>
Scroll to Top
AllEscort