wpf Page页与Frame的连接

来源:互联网 发布:rbf神经网络 python 编辑:程序博客网 时间:2024/05/16 14:19

1.新建WPF项目,在设计器中拖入Frame控件(工具箱Ctrl+w+x),外加Button控件

  <Grid>        <Frame Height="329" HorizontalAlignment="Left" Margin="12,93,0,0" Name="frame1" VerticalAlignment="Top" Width="554" />        <Button Content="点击" Height="23" HorizontalAlignment="Left" Margin="12,25,0,0" Name="button1" VerticalAlignment="Top" Width="75" />    </Grid>

2.在wpf默认命名空间下添加页(默认为Page1),再此我拖入label控件以便示范效果。


3.双击Button控件,在button_click事件方法下编写引入代码

 private void button1_Click(object sender, RoutedEventArgs e)        {            Page1 p1 = new Page1();            frame1.Content = p1;        }

4.到此结束,F5运行,结果如图所示:


0 0
原创粉丝点击