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

Specifying binding information in constructor

$
0
0

This is more of a suggestion for Xamarin Forms binding done in C# -

It would be very interesting if you could specify the information normally supplied in a call to "SetBinding" at the point you are constructing a control using initializer syntax. This would allow C# specifications of UI layouts to flow more naturally (like xaml), and reduce the need for intermediate/temp variables.

Imagine something like this:

    page.Content = new StackLayout
    {
        Children = 
        {
            new Label {Text = "Filler",TextColor = Color.Blue, TextPropertyBinding = "ImportantText"},
            new Button {Text = "PressMe", CommandPropertyBinding = "PressCommand"}
        }
    };

or even:

    page.Content = new StackLayout
    {
        Children = 
        {
            new Label {Text = "Filler",TextColor = Color.Blue, TextPropertyBinding = vm=> vm.ImportantText},
            new Button {Text = "PressMe", CommandPropertyBinding = vm => vm.PressCommand}
        }
    };

Others agree? I know there are some complexities in this, but it would be very slick I believe.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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