2016-04-15 6 views
0

ではありませんメインウィンドウのコードは次のようである:C#のWPFユーザーコントロールがウィンドウに

<Window x:Class="UserGUI.MainWindow" 
    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:local="clr-namespace:UserGUI" 
    mc:Ignorable="d" 
    Title="MainWindow" Height="657.278" Width="952.33" ResizeMode="CanMinimize"> 
<Canvas> 
    <ContentControl Name="mainContentControl" Grid.Column="0" Height="585" Width="934" Canvas.Top="31"/> 
    <ContentControl Name="upperMenu" Grid.Column="1" Height="31" Width="944"/> 
</Canvas> 

とXAMLは次のとおりです。

 public MainWindow() 
    { 
     InitializeComponent(); 
     mainContentControl.Content = new AdminMenu(); 
     upperMenu.Content = new LoginScreen(); 
    } 

しかし、私は私のメインウィンドウにユーザーコントロールが表示されません。 .. それは全く整列していないようです
私は間違っていますか?

<Canvas x:Name="loginCanvas" Background="BlanchedAlmond" Height="620" VerticalAlignment="Top" HorizontalAlignment="Left" Width="934"> 

とユーザーコントロールのウィンドウ自体のウィンドウには、次のとおりです: LoginScreenキャンバスです

Height="630" Width="944"> 

希望は、私は十分にあなたのXAMLでいくつかの奇妙なものがあります

+0

いいえ、あなたは十分ではありません。 AdminMenuとLoginScreenとは何ですか?彼らはどこに位置していますか?すべてのコードを表示する –

答えて

0

明らかです。グリッドと列はありませんが、それに基づいていくつかの配置があります。試してみてください:

<Window x:Class="UserGUI.MainWindow" 
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:local="clr-namespace:UserGUI" 
Title="MainWindow" Height="657.278" Width="952.33" ResizeMode="CanMinimize"> 
<Canvas> 
<ContentControl Name="mainContentControl" Height="585" Width="934" Canvas.Top="31" Canvas.Left="0"/> 
<ContentControl Name="upperMenu" Canvas.Top="0" Canvas.Left="0" Height="31" Width="944"/> 
</Canvas> 
関連する問題