我在VS中构建了一个C#XAML Universal应用程序,并在页面之间进行了一些简单的导航。直到几天前,导航工作正常,您可以单击主页上的按钮,然后将您带到第二页,然后您可以单击第二页上的后退按钮并返回你回到了开始。现在,其他页面(不是主页面)单独裁剪所有项目,以便小项目甚至消失。后退按钮,只是一个200x200px的小图像,没有显示,并且在'定时器'页面,计时器文本被裁减了很多。以下是编辑器中计时器页面的屏幕截图,然后是调试程序。
以下是来源。
我怎样才能让它停止播种?我做错了什么?
以下是整个批次的下载: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";
}
}
}
答案 0 :(得分:0)
你完全弄乱了xaml布局。不知道你究竟在尝试什么。为了获得类似于您的第一个屏幕截图的布局,我将文本块中的边距从(Margin =&#34; 494,151,639,184&#34;)改为(Margin =&#34; 494,151,0,0&#34;)和设置按钮&# 39;网格位置为
Grid.Column="1"
Grid.RowSpan="2"