按钮单击C#WPF时,指向另一个xaml用户控制页面

时间:2013-04-08 08:12:17

标签: c# wpf button

当我从主窗口点击按钮时,如何从主窗口指向另一个xaml用户控制页面。

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        \\what am i suppose to write here;
    }

感谢任何帮助

我的catergory xaml上的代码

    <UserControl x:Class="KinectButton.view.Catergory"
         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" 
         d:DesignHeight="373" d:DesignWidth="480" HorizontalAlignment="Stretch" Loaded="UserControl_Loaded">

<Grid Loaded="Grid_Loaded" Name="grid1">
    <StackPanel Name="myStackPanel" Margin="1,0,120,54">
        <Image Height="319" Name="myImg" Stretch="Fill" Width="357" />
    </StackPanel>
    <Grid x:Name="ContentPanel" Margin="0,0,121,54"></Grid>


    <Label Content="Label" Name="message" Margin="2,317,121,0" />
        <Button x:Name="Button1" Content="" Margin="357,77,0,222" Click="Button1_Click">
            <Button.Background>
                <ImageBrush ImageSource="C:\Users\103159T\Desktop\KinectButton1\KinectButton\Images\AERO.png"></ImageBrush>
            </Button.Background>
        </Button>
    <Button x:Name="Button3" Content="" Margin="357,147,0,148" Click="Button3_Click">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\103159T\Desktop\KinectButton1\KinectButton\Images\MIT.png"></ImageBrush>
        </Button.Background>
    </Button>
    <Button x:Name="Button4" Content="" Margin="357,224,0,0" Height="73" VerticalAlignment="Top" Click="Button4_Click">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\103159T\Desktop\KinectButton1\KinectButton\Images\MECHATRONIC.png"></ImageBrush>
        </Button.Background>
    </Button>
    <Button x:Name="Button5" Content="" Margin="357,298,0,0" Click="Button5_Click">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\103159T\Desktop\KinectButton1\KinectButton\Images\TMT.png"></ImageBrush>
        </Button.Background>
    </Button>
    <Button x:Name="Button2" Content="" Margin="357,0,0,294" Click="Button2_Click">
        <Button.Background>
            <ImageBrush ImageSource="C:\Users\103159T\Desktop\KinectButton1\KinectButton\Images\ECC.png"></ImageBrush>
        </Button.Background>
    </Button>
</Grid>

我有一些按钮和一些图像..

1 个答案:

答案 0 :(得分:1)

打开窗口的代码非常简单

private void button1_Click(object sender, RoutedEventArgs e)
    {
        // based on your comments your window is called catergory
        var catergory = new Catergory();
        catergory.Show();
    }