Using data binding,...">

WPF: partial data binding in TextBlock

So here is mine TextBlock:

<TextBlock Text="1 Projects / 1 Issues"></TextBlock>

Using data binding, I want to replace 1 and 2 with {Binding Path=OpenProjects}and {Binding Path=OpenIssues}. What is the best way to do this?

PS I'm not married to TextBlock.

+3
source share
2 answers
<TextBlock>
  <TextBlock.Text>
    <MultiBinding StringFormat="{}{0} Projects / {1} Issues">
      <Binding Path="OpenProjects"/>
      <Binding Path="OpenIssues"/>
    </MultiBinding>
  </TextBlock.Text>
</TextBlock>
+5
source

You should see the string format

+1
source

Source: https://habr.com/ru/post/1729972/


All Articles