Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML Label Text: Binding + DynamicResource (String Format?)

For Xamarin.Forms - XAML files:

is there a way to bind the Text Property (in XAML) of a Label to a Binding + DynamicResource? Maybe with string format?

for example I tried something like this:

<Label Text="{DynamicResource resource, Binding binding, StringFormat='Resource: {0} and Binding: {1}"} />

But one cannot declare a binding if a dynamic resource is set, same problem if trying it vice versa (eg. no dynamicresource if binding already set)

  • or with a value converter that returns the binding string to "binding string + dynamic resource"? (Creating a valueconverter for this seems too overwhelming)
  • in code this might work with string.Format(...)
like image 281
Csharpest Avatar asked Aug 23 '26 01:08

Csharpest


1 Answers

Seems like MultiBinding is not supported in Xamarin.Forms applications.

This is a nice workaround that kind of implements full multibinding support for Xamarin:

http://intellitect.com/multibinding-in-xamarin-forms/

Here is a simpler implementation ready to be used:

https://gist.github.com/Keboo/0d6e42028ea9e4256715

And a discussion about the subject:

https://forums.xamarin.com/discussion/21034/multibinding-support

like image 193
Isma Avatar answered Aug 24 '26 14:08

Isma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!