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

DependencyProperty equivalent for Xamarin Forms.

$
0
0

I'm writing a XAML + MVVM project for testing porpuses. So far i haven't had any problems trying to port my Windows code to Xamarin except for the DependencyProperty. Is there a way to get it working or probably a equivalent? Here is what i want to get working:

This is the dependencyproperty i want to use in Xaml:

public static readonly DependencyProperty MethodParameterProperty =
            DependencyProperty.RegisterAttached("MethodParameter", typeof(string),
            typeof(EventBehaviour), new PropertyMetadata(IsMethodChanged));

Here the setter:

public static void SetMethodParameter(DependencyObject d, string value)
        {
            d.SetValue(MethodParameterProperty, value);
        }

Here the event called:

private static void IsMethodChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var element = d as FrameworkElement;
            if (element != null)
            {
                // Create events here
                element.PreviewMouseUp += element_PreviewMouseUp;
            }
        }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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