原文:
WPF点击不同界面上的按钮实现界面切换
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.youkuaiyun.com/qq_29844879/article/details/80207782
网上看到的都是在一个界面上使用同一个按钮实现界面切换,这里我来做个不同界面上的不同按钮实现界面切换。如下图:
可以看到右下角有个“查询数据”按钮,当点击查询按钮时切换到另一个界面,如下图:
虽然长得很像,但它们绝不是同一个按钮,当点击返回查询时,将回到前面的界面。
代码如下:
第一个界面叫DataManage,其xmal:
<UserControl x:Class="MyControlLibrarys.DataManage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Margin="10 0"
d:DesignHeight="600" d:DesignWidth="850" Loaded="UserControl_Loaded">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/GeneralStyle;component/Themes/Generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/GeneralStyle;component/Themes/DataGrid.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="120"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="