0

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

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

感谢任何帮助表示赞赏

我在我的类别 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>

我有几个按钮和一些图像。

4

1 回答 1

1

打开窗口的代码非常简单

private void button1_Click(object sender, RoutedEventArgs e)
    {
        // based on your comments your window is called catergory
        var catergory = new Catergory();
        catergory.Show();
    }
于 2013-04-08T09:08:01.963 回答