分享一个大佬写的界面跳转

这是Prism框架开发者写的一个demo,我觉得有趣,就发出来让大家看看

 <StackPanel>
     <StackPanel Orientation="Horizontal">
         <Button x:Name="AnimationButton" Click="AnimationButton_Click" Content="Animation" Background="Transparent" BorderBrush="Transparent" Margin="0,0,5,0"/>
         <Button x:Name="ConditionsButton" Click="ConditionalButton_Click" Content="Conditions" Background="Transparent" BorderBrush="Transparent" Margin="0,0,5,0"/>
         <Button x:Name="DataBehaviorButton" Click="DataBehaviorButton_Click" Content="Data behaviors" Background="Transparent" BorderBrush="Transparent" Margin="0,0,5,0"/>
     </StackPanel>
     <Grid x:Name="MainContent"/>
 </StackPanel>
 
  public partial class MainWindow : Window
 {
     private AnimationPage animationPage;
     private ConditionPage conditionPage;
     private DataPage dataPage;

     public MainWindow()
     {
         InitializeComponent();
         animationPage = new AnimationPage();
         conditionPage = new ConditionPage();
         dataPage = new DataPage();
         this.MainContent.Children.Add(animationPage);
     }

     private void AnimationButton_Click(object sender, RoutedEventArgs e)
     {
         this.MainContent.Children.Clear();
         this.MainContent.Children.Add(this.animationPage);
     }

     private void ConditionalButton_Click(object sender, RoutedEventArgs e)
     {
         this.MainContent.Children.Clear();
         this.MainContent.Children.Add(this.conditionPage);
     }

     private void DataBehaviorButton_Click(object sender, RoutedEventArgs e)
     {
         this.MainContent.Children.Clear();
         this.MainContent.Children.Add(this.dataPage);
     }
 }
posted @ 2024-08-04 18:43  孤沉  阅读(6)  评论(0编辑  收藏  举报