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

Custom view load with live updates

$
0
0

I've created a custom view, which I've rendered for use in a xamarin.forms view.

I'm able to update the view using the OnElementPropertyChanged method:

protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
    base.OnElementPropertyChanged(sender, e);

    if (e.PropertyName == myClassPortable.myVariableProperty.PropertyName)
    {
        Control.myVariable = Element.myVariable;
    }
}

This is along with ensuring I have the bindable requirements set up in my portable class:

public static readonly BindableProperty myVariableProperty =
    BindableProperty.Create<myClassPortable, int> (
        v => v.myVariable, default(int));

public int myVariable
    {
        get { return(int)GetValue(myVariableProperty); }
        set { SetValue(myVariableProperty, value); }
    }

Whenever I set the variable:

myClassInstance.myVarible = 1;
Then the view is updated. But if I want to get whatever the variable is set to. Then the 'getter' never seems to be activated.

int myInt = myClassInstance.myVariable;

Just for some added info: The particular view I've created is an analogue stick, so what I actually need is for the values, angle, direction, and power to be updated when the user touches it. I'm then intending to get these values and display them (at least for now)

Do I need to get the views variable in a different way?``


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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