XAML StackPanel 在其他页面裁剪项目

XAML StackPanel cropping items on other page

我正在 VS 中构建一个 C# XAML 通用应用程序,在页面之间进行一些简单的导航。直到几天前,导航都工作正常,你可以点击主页上的一个按钮,它会带你到第二页,然后你可以点击第二页上的后退按钮,它 return你回到起点。现在,其他页面(不是主页)正在单独裁剪所有项目,因此小项目甚至消失了。后退按钮只是一个 200x200 像素的小图像,没有显示,并且在 'Timer' 页面上,计时器文本被裁剪了很多。这是编辑器中定时器页面的屏幕截图,然后是调试程序中的屏幕截图。

下面是来源。

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

这里是全部下载:https://mega.nz/#!2gskULpZ!ExddgKx083jCTXzCetpgtE4li_rTcupsvCWLOZvK2Kg

谢谢!

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;
            }
        }
    }
}

和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";
        }
    }
}

你完全搞砸了 xaml 布局。不知道你到底想达到什么目的。为了获得类似于您的第一个屏幕截图的布局,我将文本块的边距从 (Margin="494,151,639,184") 更改为 (Margin="494,151,0,0") 并将按钮的网格位置设置为

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