Reputation: 21
I have custom Picker with property
public EventHandler SelectedIndexChanged { get; set; }
and i want set this property from xaml.
like this GenderPicker.SelectedIndexChanged += GenderPicker_OnSelectedIndexChanged;
but from xaml
<elements:CustomPicker
SelectedIndexChanged="{What write there???}"/>
Upvotes: 2
Views: 1004
Reputation: 34128
Just write the name of the method like Handle_SelectedIndexChanged
and make sure that you create the method in your code-behind of the page where you are using the control, with the right signature, for instance:
private void Handle_SelectedIndexChanged(object sender, EventArgs args)
{
// ... your code here
}
Upvotes: 2
Reputation: 133
You should be able to just press tab after you select an event handler and it will auto generate it in the code behind for you to add whatever logic you want. However, you if you are trying to use bindings it is slightly more complicated. You will need an ItemsSource.
ItemsSource="{Binding SelectedIndexChanged}"
In the view model you will also need-
public PickerFlyout Foo { get; set; }
And in the start you will need initialize what is in the picker.
Upvotes: 1