Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Binding with Converter using ConverterParameter Binding Not Working

$
0
0

I'm trying to do the following:

Bind a Color property from based on the class property if the item is selected. If it is not selected, to color the Color gray. This is using a custom horizontal RepeaterView. The IsSelected property is a property on my object class which gets set to true in the repeaterview when the item has been clicked:

[ImplementPropertyChanged] //PropertyChanged.Fody implements events as needed for binding automatically
public class Child : ISelectable
{
        public bool IsSelected { get; set; }
        public Color IdentityColor { get; set; }
}

BorderColor="{Binding IsSelected, Converter={StaticResource ChildSelectedColorConverter}}"

I've tried

BorderColor="{Binding IsSelected, Converter={StaticResource ChildSelectedColorConverter}, ConverterParameter={Binding IdentityColor}}"

and it did not work because from what I've read, you can't bind a property to the ConverterParameter because it is not a Dependency/Bindable Object.

I've also tried binding directly to the object, as follows and updating the converter to check the IsSelected and pass back the IdentityColor, but it doesn't updated the BorderColor when the IdentityColor has changed, I believe due to the fact that I'm binding against the whole object and it isn't being notified on the IsSelected being changed:

BorderColor="{Binding ., Converter={StaticResource ChildSelectedColorConverter}}"

Is it possible to make the {Binding .} propertychanged notify for the whole object when a child property has changed?

Since MultipleBindings aren't available in Xamarin.Forms yet, how can I get this to work as needed?

Thanks for your help,

John


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>