Bernd Morgeneyer
Bernd Morgeneyer

Reputation: 109

Xamarin.Forms: Get PropertyInfo from Binding information

In XAML I define some elements, e.g. ToolbarItems:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:vm="clr-namespace:MyNamespace.ViewModels" 
             x:DataType="vm:MyViewModel"
             x:Class="MyNamespace.Views.MyPage"
             Title="{Binding Title}" >
...
    <ToolbarItem x_Name="ThisItem" Text="Some text" Command="{Binding SomeCommand}" CommandParameter="Some parameter" />

In Code Behind I need the System.Reflection.PropertyInfo of property SomeCommand defined in XAML by the Binding information.

Is this possible?

Upvotes: 0

Views: 64

Answers (1)

Bernd Morgeneyer
Bernd Morgeneyer

Reputation: 109

I decided to remove the Command assignment in XAML and define it in Code Behind only. It would have been tricky to obtain the PropertyInfo for "SomeCommand" from the XAML Binding information and use it for the different ViewModels.

Upvotes: 0

Related Questions