C# XAML StackPanel裁剪其他页面上的项目

C# XAML StackPanel裁剪其他页面上的项目,c#,xaml,universal,C#,Xaml,Universal,我正在VS中构建一个C#XAML通用应用程序,在页面之间进行一些简单的导航。直到几天前,导航还可以正常工作,你可以点击主页上的一个按钮进入第二页,然后你可以点击第二页上的一个后退按钮,它会让你回到起点。现在,其他页面(不是主页)正在逐个裁剪所有项目,这样小项目甚至会消失。后退按钮只是一个200x200px的小图像,没有显示,在“计时器”页面上,计时器文本被大幅裁剪。下面是编辑器中计时器页面的屏幕截图,然后是调试程序中的 以下将是来源 我怎样才能让它停止修剪?我做错了什么 以下是全部内容的下载

我正在VS中构建一个C#XAML通用应用程序,在页面之间进行一些简单的导航。直到几天前,导航还可以正常工作,你可以点击主页上的一个按钮进入第二页,然后你可以点击第二页上的一个后退按钮,它会让你回到起点。现在,其他页面(不是主页)正在逐个裁剪所有项目,这样小项目甚至会消失。后退按钮只是一个200x200px的小图像,没有显示,在“计时器”页面上,计时器文本被大幅裁剪。下面是编辑器中计时器页面的屏幕截图,然后是调试程序中的

以下将是来源

我怎样才能让它停止修剪?我做错了什么

以下是全部内容的下载:

谢谢

timer.xaml:

    <Page
    x:Class="CubingHelper.Timer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:CubingHelper"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid x:Name="TimerBG">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="23*"/>
            <ColumnDefinition Width="1898*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="728*"/>
            <RowDefinition Height="353*"/>
        </Grid.RowDefinitions>
        <Grid.Background>
            <SolidColorBrush Color="{StaticResource BGCol}"/>
        </Grid.Background>

        <TextBlock x:Name="TimerText" Text="0.00" Margin="494,151,639,184" FontFamily="extravaganzza" FontSize="340" RenderTransformOrigin="0.696,0.733" Grid.Column="1" >
            <TextBlock.Foreground>
                <SolidColorBrush Color="{StaticResource ForeGroundText}"/>
            </TextBlock.Foreground>
        </TextBlock>


        <Button Height="724" Width="296" Click="BackButton_Click" Margin="0,0,0,3" Background="#33000000" Grid.ColumnSpan="2">
            <Button.Template>
                <ControlTemplate>
                    <Image x:Name="BackImg" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" RenderTransformOrigin="-2.5,-1.59" Source="Assets/BackButton.png" />
                </ControlTemplate>
            </Button.Template>
        </Button>
    </Grid>
</Page>

Timer.xaml.cs:

    using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Windows.Input;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI.Core;
using Windows.System;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace CubingHelper
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class Timer : Page
    {
        public Timer()
        {
            this.InitializeComponent();
        }


        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(MainPage));
        }


        private void KeysDown(object sender, KeyEventArgs e)
        {
            if (e.VirtualKey == VirtualKey.Space)
            {
                TimerText.FontSize = 200;
            }
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用System.Windows.Input;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
使用Windows.UI.Core;
使用Windows.System;
//空白页项模板被记录在http://go.microsoft.com/fwlink/?LinkId=234238
命名空间CubingHelper
{
/// 
///可以单独使用或在框架内导航到的空页。
/// 
公共密封部分类计时器:第页
{
公共计时器()
{
this.InitializeComponent();
}
专用无效BackButton_单击(对象发送方,路由目标)
{
此.Frame.Navigate(typeof(MainPage));
}
私有void KeysDown(对象发送方,KeyEventArgs e)
{
if(e.VirtualKey==VirtualKey.Space)
{
TimerText.FontSize=200;
}
}
}
}
和MainPage.xaml.cs:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace CubingHelper
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>

    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            appView.Title = "Home";
        }


        private void PLL_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(PLL));
            var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            appView.Title = "PLL";
        }

        private void OLL_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(OLL));
            var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            appView.Title = "OLL";
        }

        private void Timer_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(Timer));
            var appView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
            appView.Title = "Timer";
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.IO;
使用System.Linq;
使用System.Runtime.InteropServices.WindowsRuntime;
使用Windows基金会;
使用Windows。
使用Windows.UI.Xaml;
使用Windows.UI.Xaml.Controls;
使用Windows.UI.Xaml.Controls.Primitives;
使用Windows.UI.Xaml.Data;
使用Windows.UI.Xaml.Input;
使用Windows.UI.Xaml.Media;
使用Windows.UI.Xaml.Navigation;
//空白页项模板被记录在http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
命名空间CubingHelper
{
/// 
///可以单独使用或在框架内导航到的空页。
/// 
公共密封部分类主页面:第页
{
公共主页()
{
this.InitializeComponent();
var appView=Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.Title=“主页”;
}
私有无效PLL_单击(对象发送器,路由目标e)
{
此.Frame.Navigate(typeof(PLL));
var appView=Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.Title=“PLL”;
}
私有无效OLL_单击(对象发送方,路由目标)
{
this.Frame.Navigate(typeof(OLL));
var appView=Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.Title=“OLL”;
}
私有无效计时器\u单击(对象发送器,路由目标)
{
this.Frame.Navigate(typeof(Timer));
var appView=Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();
appView.Title=“计时器”;
}
}
}

您完全弄乱了xaml布局。不知道你到底在努力实现什么。为了获得与第一个屏幕截图相似的布局,我将文本块的边距从(margin=“494151639184”)更改为(margin=“494151,0,0”),并将按钮的网格位置设置为

Grid.Column="1"
Grid.RowSpan="2"

这有点帮助,但这意味着按钮必须在屏幕中央,这显然是我不想要的。我如何才能得到它,使整个按钮显示,但它在屏幕上的正确位置?