I struggled with the same problem and did not get the data I needed. You cannot be attached to the "converter parameter", that is, how it is done on the current date. But I really wanted to get some data sent to the parameter. so I found a simple but working solution, and I hope that it can work for you too. Start by providing CompareTo x: Name = "CompareTo" or whatever you want to name.
<Element Attribute="{Binding Value, Converter={StaticResource EqualityConverter}, ConverterParameter={x:reference CompareTo}}" />
By doing x: referring to its actually sending some data, you just have to capture it. For me, the value I needed was the value "string" so that I could follow certain "If" instructions. This way you can do something similar to:
if(CompareTo == "myCoolString") { Value = "Well i guess i'm not so cool!" }
This is how I got the data from the parameter:
public class MyConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (parameter != null) { try { var image = parameter as Image; var src = image.Source as FileImageSource; if (src.File.ToString() == "coolimage.png") { return "thumbsup.png"; } } catch { } } }
In my case, I was working with an image and needed to find out if there was one image “A” and then “B” in order to change the image “C”. This should work with other objects. A little lucky, this brings you closer to some simplified "Multibinding" and answer.
Hope this has been helpful since this is my first post on Stackoverflow!
Victor Eriksson
source share