2

I have a problem trying to convert existing XAML to MultiBinding.
The current code (which needs to be replaced) is

<TextBlock  Text="{Binding BarcodeCollection.Count}" />
<TextBlock  Text="{x:Static p:Resource.AllWN}" />


What I have now:

<control:MyControl>
    <control:MyControl.ControlText>
        <MultiBinding StringFormat="{}{0} {1}">
            <Binding Path="BarcodeCollection.Count"/> <!-- This part works fine -->
            <Binding ??? /> <!-- No idea how to re-write this part -->
        </MultiBinding>
    </control:MyControl.ControlText>
</control:MyControl>

I tried many things I could think of to make the 2nd part working but couldn't figure it out. I tried using Path but it's not a path so obviously it didn't work. I also tried all kinds of variations through StringFormat, Source & RelativeSource but nothing seemed to work.

Anyone have any ideas? Is it even possible?

Tzah Mama
  • 1,547
  • 1
  • 13
  • 25

2 Answers2

3

You have to set Source like this:

<Binding Source="{x:Static p:Resource.AllWN}"/>
Rohit Vats
  • 79,502
  • 12
  • 161
  • 185
  • 1
    Thanks! I don't know why my usage of `Source` didn't worked out in the first place but you now saved me a lot of headache! – Tzah Mama Jul 30 '14 at 13:58
1

According to the https://stackoverflow.com/a/3341536/1157021 the source should work in this form:

<Binding Source="{StaticResource p:Resource.AllWN}" />
Community
  • 1
  • 1
Honza Kovář
  • 704
  • 6
  • 9
  • This won't work because for this resource has to be defined in XAML. But OP is binding it with static value from ViewModel. – Rohit Vats Jul 30 '14 at 13:55