W
W
WayMax2017-12-01 15:18:18
css
WayMax, 2017-12-01 15:18:18

Binding StringFormat (WPF) not working?

We need binding with displaying not just the value, but also our own text.
Found this option:

<DockPanel>
    <Label Content="{Binding StringFormat=Выбрано {0} единиц, ElementName=slider1, Path=Value}" DockPanel.Dock="Top"/>
    <Slider Name="slider1" Value="50" Maximum="100" IsSnapToTickEnabled="True" DockPanel.Dock="Top"/>
</DockPanel>

But only a number is displayed on the screen.
Then I found what needs to be screened, tried it and all the same on the screen only a number without text. Microsoft Visual Studio Community 2015 Microsoft NET Framework 4.5.2 Nothing prevents you from changing the version of the studio or framework, if necessary. Выбрано \{0\} единицВыбрано {}{0} единиц

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lam0x86, 2017-12-01
@WayMax

<Label
  Content="{Binding ElementName=slider1, Path=Value}"
  ContentStringFormat="{}Выбрано {0} единиц"
  DockPanel.Dock="Top"
/>

P
Peter, 2017-12-01
@petermzg

<Label Content="{Binding StringFormat='{}Выбрано {0} единиц', ElementName=slider1, Path=Value}" DockPanel.Dock="Top"/>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question