我使用syncfusion计划,我使用标签页显示2个不同的每日时间表:
MainPage = new TabbedPage{
Children =
{
new DailyView(),
new DailyViewMaterials()
}
};
两页DailyView和DailyViewMaterials具有相同的样式:上面有2个标签,然后是synycfusion时间表,但是时间表有不同的数据源和不同的约会。
当我运行项目并单击约会时,它将显示包含约会详细信息的框架。首先,它工作正常,但当我切换到第二页,然后切换回第一页,然后点击约会,它会触发第二个时间表的任命解决方案的任命解决方案?
编辑:
<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");
}
}
谢谢