Last active
September 29, 2020 09:33
-
-
Save mr5z/e5dcb22bf70799698a9cadcc9c78abcf to your computer and use it in GitHub Desktop.
bla bla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static BindableProperty <insert the object nameof(Property) here> + Property = CreateProperty<T>(nameof(<insert the object nameof(Property) here>)); | |
public T <insert the object nameof(Property) here> | |
{ | |
get => (T)GetValue(<insert the object nameof(Property) here> + Property); | |
set => SetValue(<insert the object nameof(Property) here> + Property, value); | |
} | |
// TODO put this under Utility folder | |
public static BindableProperty CreateProperty<T>(string propertyName, T defaultValue = default, BindingMode mode = BindingMode.TwoWay) | |
{ | |
return BindableProperty.Create(propertyName, typeof(T), typeof(BindableObject), defaultValue, mode); | |
} | |
// Example use case | |
public static BindableProperty MiddleButtonCommandProperty = CreateProperty<ICommand>(nameof(MiddleButtonCommand)); | |
public ICommand MiddleButtonCommand | |
{ | |
get => (ICommand)GetValue(MiddleButtonCommandProperty); | |
set => SetValue(MiddleButtonCommandProperty, value); | |
} |
public static BindableProperty LabelHeight = BindableHelper.CreateProperty(LabelHeight);
Correct?
yes. I'll give another example.
it can't find BindableHelper
Some missing reference?
This is what I have currently used:
public static BindableProperty LabelHeight = BindableProperty.Create("LabelHeight", typeof(double), typeof(double), DeviceDisplay.MainDisplayInfo.Height);
public BindableObject LabelHeightObject
{
get => (BindableObject) GetValue(LabelHeight);
set => SetValue(LabelHeight, value);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
public static BindableProperty LabelHeight = BindableHelper.CreateProperty(LabelHeight);
Correct?