I'm trying to add a RightTapped
event to each CalendarViewDayItem
. DoubleTapped
event works fine, but RightTapped
is not raised despite of that it's created.
This is how I have created them:
private void calviewSun_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
{
args.Item.DoubleTapped = CalendarViewDayItem_DoubleTapped;
args.Item.RightTapped = CalendarViewDayItem_RightTapped;
}
I have tried setting breakpoints to check if they were raised but they had any other problems, but they are never raised. I have check that args.Item.IsRightTapEnbaled
is set to true.
I don't know why is not raising the event.
CodePudding user response:
Please try to use UIElement.AddHandler() Method to add right tapped event for the CalendarViewDayItem
.
The code looks like this:
private void CalendarView_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
{
args.Item.IsRightTapEnabled = true;
args.Item.DoubleTapped = Item_DoubleTapped;
// args.Item.RightTapped = Item_RightTapped;
args.Item.AddHandler(UIElement.RightTappedEvent, new RightTappedEventHandler(Item_RightTapped), true);
}
private void Item_RightTapped(object sender, RightTappedRoutedEventArgs e)
{
Debug.WriteLine("RightTapped");
}