1

我正在使用同步融合时间表,我使用标签页显示 2 个不同的每日时间表:

MainPage = new TabbedPage{
  Children =
  {
      new DailyView(),
      new DailyViewMaterials()
  }
};

DailyView 和 DailyViewMaterials 两个页面的样式相同:上面有 2 个标签,然后是一个同步时间表,但时间表有不同的数据源和不同的约会。

当我运行项目并单击约会时,它将显示一个包含约会详细信息的框架。首先它工作正常,但是当我切换到第二页,然后切换回第一页并单击一个约会时,它会触发第二个时间表的约会点击事件,有什么解决方案吗?

编辑:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:local="clr-namespace:eAgenda1"
         xmlns:ViewModels="clr-namespace:eAgenda1.ViewModels;assembly=eAgenda1"
         xmlns:Models="clr-namespace:eAgenda1.Models;assembly=eAgenda1"
         xmlns:ActivitiesDailySchedule="clr-namespace:Syncfusion.SfSchedule.XForms;assembly=Syncfusion.SfSchedule.XForms"
         x:Class="eAgenda1.DailyView"
         Title="Activities"
         BackgroundColor="White">
    <ContentPage.BindingContext>
      <ViewModels:ActivitiesViewModel/>
    </ContentPage.BindingContext>
    <ContentPage.Padding>
     <OnPlatform x:TypeArguments="Thickness"  iOS="0, 20, 0, 0" Android="0"  WinPhone="0" />
    </ContentPage.Padding>
<StackLayout x:Name ="acitivitiesMainStack"
           HorizontalOptions="FillAndExpand"
           VerticalOptions="FillAndExpand">
<Label x:Name="dateLabel"
       HorizontalOptions="Center"
       VerticalOptions="Center"
       FontSize="Large"/>
<Label x:Name="weekLabel"
       HorizontalOptions="End"
       HorizontalTextAlignment="Center"/>
<ActivitiesDailySchedule:SfSchedule x:Name="activitiesSchedule"
                          BackgroundColor="White"
                          HorizontalOptions="FillAndExpand"
                          VerticalOptions="FillAndExpand"
                          ScheduleView="DayView"
                          ShowAppointmentsInline="True"
                          DataSource="{Binding ActivitiesCollection}"
                         ScheduleCellTapped="ActivitiesSchedule_CellTapped">
</ActivitiesDailySchedule:SfSchedule>
<Frame x:Name="appointmentDetailsFrame"
       VerticalOptions="CenterAndExpand"
       OutlineColor="Accent"
       IsVisible="False">
  <StackLayout>
    <StackLayout Orientation="Horizontal">
      <StackLayout HorizontalOptions="Start">
        <Label x:Name="subjectLabel"
          FontSize="Large"/>
        <Label x:Name="descriptionLabel"
               FontSize="Medium"/>
      </StackLayout>
      <StackLayout HorizontalOptions="EndAndExpand">
        <Label x:Name="typeLabel"
               HorizontalTextAlignment="End"
               FontSize="Medium"/>
        <Label x:Name="timeLabel"
               HorizontalTextAlignment="End"
               FontSize="Small"/>
      </StackLayout>
    </StackLayout>
    <Button x:Name="cancelButton"
            Text="OK"
            Clicked="CancelClicked"/>
  </StackLayout>
</Frame>

以及背后的代码:

 void CancelClicked(object sender, EventArgs args)
    {

        appointmentDetailsFrame.IsVisible = false;
        activitiesSchedule.IsVisible = true;
    }
    void ActivitiesSchedule_CellTapped(object sender, ScheduleTappedEventArgs args)
    {
        if (args.selectedAppointment != null)
        {    
            activitiesSchedule.IsVisible = false;
            appointmentDetailsFrame.IsVisible = true;
            var selectedAppointment = (Activity)args.selectedAppointment;
            typeLabel.Text = selectedAppointment.Type;
            subjectLabel.Text = selectedAppointment.Subject;
            descriptionLabel.Text = selectedAppointment.Description;
            timeLabel.Text = selectedAppointment.Time;
            System.Diagnostics.Debug.WriteLine(selectedAppointment.Type);
        }

        else
        {
            System.Diagnostics.Debug.WriteLine("No activities");
        }
    }

谢谢

4

0 回答 0