I have a navigationview and I want to pass extra argument to selection_changed event
MUXC.NavigationView navigationview = new MUXC.NavigationView();
navigationview.SelectionChanged += new EventHandler((s, e) => Navigationview_SelectionChanged(s, e, param));
getting error for above code
Cannot implicitly convert type 'System.Eventhandler' to 'Windows.Foundation.TypedEventHandler'
When attaching events, there is usually no need to new an EventHandler
, because the type of NavigationView.SelectionChanged
is TypedEventHandler , direct assignment will cause the type to mismatch.
If you create a SelectionChanged
event handle method, you can attach it like this:
var navigationview = new muxc.NavigationView();
navigationview.SelectionChanged += Navigationview_SelectionChanged;
private void Navigationview_SelectionChanged(muxc.NavigationView sender, muxc.NavigationViewSelectionChangedEventArgs args)
{
// Do something...
}
From your code, you seem to have created a method with three parameters. If you need to keep the param
, then you need to perform some conversion.
navigationview.SelectionChanged += (_s, _e) =>
{
Navigationview_SelectionChanged(_s, _e, param);
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.