Label is not a valid XAML element?

I tried to run my C#/XAML app again this morning (earlier problems noted here: Why did my XAML suddenly crash?).

This time, I at least got some specific err msgs, namely "The member "ShowGridLines" is not recognized or is not accessible." and "Label is not supported in a Windows App project."

Here is the complete 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>

Note: with the only difference being that the initial and namespace portion of the XAML is simply this:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

...and that there is no Background="{StaticResource ApplicationPageBackgroundThemeBrush}" in the Grid properties, this XAML displays as it should (very ugly for now, but that's to be expected at this point) in Kaxaml.

Upvotes: 2

Views: 2151

Answers (1)

Peter Hansen
Peter Hansen

Reputation: 8907

You have written some XAML that is only supported for WPF apps and not for WinRT.
WinRT does not contain a Label control and the Grid has no ShowGridLines property, which is why your code is not working properly.

WPF and WinRT are two separate technologies - both happen to use XAML to create the user interface - but you shouldn't expect that XAML written in WPF will work in WinRT and vice versa.

Upvotes: 2

Related Questions