zoukankan      html  css  js  c++  java
  • [C# WPF] 根据按钮动态跳转窗体

    WPF 根据按钮动态跳转窗体

    XMAL文件中,用Tag保存要跳的页面

    <Button Name="btnWindow01" Content="ClickMe" Width="100" Height="30" Click="btnNavigate_Click" Tag="SubWindow01"></Button>
    <Button Name="btnWindow02" Content="ClickMe" Width="100" Height="30" Click="btnNavigate_Click" Tag="SubWindow02"></Button>
    
            private void btnNavigate_Click(object sender, RoutedEventArgs e)
            {
                Type type = this.GetType();
                Assembly assembly = type.Assembly;
                Window win = assembly.CreateInstance(type.Namespace + "." + (sender as Button).Tag) as Window;
    
                win.Show();
                // or
                win.ShowDialog();
            }
    

    作者:码路工人

    公众号:码路工人有力量(Code-Power)

    欢迎关注个人微信公众号 Coder-Power

    一起学习提高吧~

  • 相关阅读:
    6、查看历史记录
    A Tour of Go Range
    Go Slices: usage and internals
    A Tour of Go Nil slices
    A Tour of Go Making slices
    A Tour of Go Slicing slices
    A Tour of Go Slices
    A Tour of Go Arrays
    A Tour of Go The new function
    A Tour of Go Struct Literals
  • 原文地址:https://www.cnblogs.com/CoderMonkie/p/wpf-window-navigation.html
Copyright © 2011-2022 走看看