【发布时间】:2012-10-31 17:39:35
【问题描述】:
今天早上我再次尝试运行我的 C#/XAML 应用程序(此处提到的早期问题:Why did my XAML suddenly crash?)。
这一次,我至少得到了一些具体的错误消息,即“成员“ShowGridLines”无法识别或无法访问。”和“Windows 应用项目不支持标签。”
这是完整的 XAML:
<Page
x:Class="TimeAndSpaceLines.View.SectionN"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:TimeAndSpaceLines.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid MinHeight="600" ShowGridLines="True" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="320"></ColumnDefinition>
<ColumnDefinition MaxWidth="800"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Label MinWidth="40" Content="From"></Label>
<TextBox x:Name="textBoxFromDate" MinWidth="120">
</TextBox>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label MinWidth="40">at
</Label>
<TextBox x:Name="textBoxFromTime" MinWidth="120" Grid.Row="1">
</TextBox>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Label MinWidth="40">To
</Label>
<TextBox x:Name="textBoxToDate" MinWidth="120">
</TextBox>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal">
<Label MinWidth="40">at
</Label>
<TextBox x:Name="textBoxToTime" MinWidth="120" Grid.Row="1">
</TextBox>
</StackPanel>
<Button
x:Name="buttonFindLocForDateRange"
MaxWidth="200"
Grid.Row="4"
Content="Find Location for Date Range">
</Button>
<Label
x:Name="labelPerson1_Red"
Grid.Row="5"
Content="(Person1_Red)"
Foreground="Red">
</Label>
<Label
x:Name="labelPerson2_Orange"
Grid.Row="6"
Content="(Person2_Orange)"
Foreground="Orange">
</Label>
<Label
x:Name="labelPerson3_Yellow"
Grid.Row="7"
Content="(Person3_Yellow)"
Foreground="Yellow">
</Label>
<Label
x:Name="labelPerson4_Green"
Grid.Row="8"
Content="(Person4_Green)"
Foreground="Green">
</Label>
<Label
x:Name="labelPerson5_Blue"
Grid.Row="9"
Content="(Person5_Blue)"
Foreground="Blue">
</Label>
<Label
x:Name="labelPerson6_Indigo"
Grid.Row="10"
Content="(Person6_Indigo)"
Foreground="Indigo">
</Label>
<Label
x:Name="labelPerson7_Violet"
Grid.Row="11"
Content="(Person7_Violet)"
Foreground="Violet">
</Label>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Image>
</Image>
<Label>Prev
</Label>
<Label x:Name="labelSectionN" Content="(Section N)">
</Label>
<Label>Next
</Label>
</StackPanel>
<!-- Add a Bing Map component: Grid.Column="1" Grid.Row="1" Grid.RowCount="11" -->
</Grid>
</Page>
注意:唯一的区别是 XAML 的初始和命名空间部分是这样的:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...并且在 Grid 属性中没有 Background="{StaticResource ApplicationPageBackgroundThemeBrush}",此 XAML 在 Kaxaml 中显示为应有的效果(目前非常难看,但此时这是可以预料的)。
【问题讨论】:
-
缺少早期问题的链接。另外,请注意,您可以像 RowDefinition 这样自行关闭标签,例如
<RowDefinition/>而不是<RowDefinition></RowDefinition> -
谢谢;我会添加链接(有时我觉得自己是缺少的链接);并感谢您的提示。
-
确定一下 - 您正在开发 Windows 应用商店 (WinRT) 应用程序,对吗?而不是 WPF 应用程序?
-
是的,我使用了模板 |视觉 C# | Windows 商店 |拆分应用 (XAML) 作为我的起点。
-
是的,它做到了:删除“ShowGridRows”,用 TextBlock 替换 Label,用 Text 替换 Content 让它再次运行。如果你把你的答案写在下面,彼得,我会用绿色勾选它。这也很有帮助:xamlsource.net/winrt
标签: wpf xaml windows-8 visual-studio-2012 winrt-xaml