WPF - 派生窗口的内容未显示

时间:2016-04-30 07:59:27

标签: c# wpf xaml

我正在尝试创建一个自定义控件,我希望我的Window类可以从中获取它们的功能。

public class BaseWindow : Window
{
   protected int x;
   public BaseWindow(int x) {this.x = x;}
   public void Window_KeyDown(object sender, KeyEventArgs e)
    {
          //code
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
        //code
    }
}

现在派生类.cs

public class SubWindow : BaseWindow
{
   public SubWindow(int x):base(x)
   {
          InitializeComponent();
   }
 }

和SubWindow的xaml

<src:BaseWindow x:Class="Client.SubWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:src="clr-namespace:Client"  
    mc:Ignorable="d"
    Title="Singleplayer" Height="350" Width="550"
    MinHeight="350" MinWidth="550"
    KeyDown="Window_KeyDown"
    >
<Grid  Margin="58,-160,-58,160">
    <StackPanel>

        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical" FlowDirection="RightToLeft">

            <StackPanel Margin="0,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal" FlowDirection="LeftToRight">

                <Image  Width="60" Height="60"/>
                <Label FontSize="40" Margin="0,0,0,0" FlowDirection="LeftToRight" HorizontalContentAlignment="Center" TextBlock.Foreground="White" RenderTransformOrigin="0.5,0.5" Content="Title">
                    <Label.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform AngleX="-4.826"/>
                            <RotateTransform/>
                        </TransformGroup>
                    </Label.RenderTransform>
                </Label>
            </StackPanel>
        </StackPanel>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Background="White" Opacity=".9" Margin="5,0,5,0" Content="text1"/>
            <Button Background="White" Opacity=".9" Margin="5,0,5,0" Content="text2"/>
            <Button Background="White" Opacity=".9" Margin="5,0,5,0" Content="text3?"/>
        </StackPanel>
        <Grid HorizontalAlignment="Left" Height="88" Margin="124,182,0,0" VerticalAlignment="Top" Width="56"/>
    </StackPanel>

 </Grid>
</src:GameWindow>

现在打开SubWindow时,它是空的。没有堆栈窗格或任何东西只有一个 黑色background.if我使用相同的xaml和代码没有继承 窗口显示出来。

所以我在这里失踪了什么? (我删除了很多原始代码以使其可读,我希望我的问题仍然存在于我离开的代码中)

谢谢!

0 个答案:

没有答案