I'm writing a custom viewcell with bindable properties. I'd like to look at the bound property and get any custom attributes applied to it... in this case, specifically the DisplayNameAttribute. Is it possible to do this? I know how to look at a property and get it's attributes, but can't figure out the disconnect caused by it being just a property value in my control's view model.
Example:
View model has
public ValidatableObject<string> username; [DisplayName("Foo")] public ValidatableObject<string> UserName { get => this.username; set { this.username = value; NotifyPropertyChanged(); } }
It'd bind to my control like
<my:SpecialCell Value="{Binding UserName}" />
Code is
public static readonly BindableProperty ValueProperty = BindableProperty.Create(nameof(Value), typeof(ValidatableObject<string>), typeof(ValidatedEntryCell), default(ValidatableObject<string>), BindingMode.TwoWay); public ValidatableObject<string> Value { get { return (ValidatableObject<string>)GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } }
Elsewhere in the view model, I'd like to get "Foo" if it has been attached to the property, in order to use it as the default value of a label.