WP7 Usercontrol无法在MainPage.xaml中引用

时间:2012-03-07 09:55:54

标签: windows-phone-7 user-controls panorama-control

这就是我的MainPage的样子:

<phone:PhoneApplicationPage 
x:Class="EnergyRadio.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:local="clr-namespace:EnergyRadio"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" 
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"  Orientation="Portrait"
shell:SystemTray.IsVisible="False">

<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">

    <!--Panoramasteuerelement-->
    <controls:Panorama Title="Radio">
        <controls:Panorama.Background>
            <ImageBrush ImageSource="PanoramaBackground.png"/>
        </controls:Panorama.Background>

        <!--Panoramaelement one-->
        <controls:PanoramaItem Header="CHANNELS">
             <!--First Panaroma Items HARD CODED-->
        </controls:PanoramaItem>

        <controls:PanoramaItem Header="KONTAKT">
            <!--Kontakt.xaml should be shown here.-->
        </controls:PanoramaItem>
    </controls:Panorama>
</Grid>

这是我的Kontakt.xaml

<UserControl x:Class="EnergyRadio.Kontakt"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:EnergyRadio"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">

<Grid x:Name="LayoutRoot">
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Image  HorizontalAlignment="Left" Margin="624,153,0,0" Name="wemf" Stretch="Fill" VerticalAlignment="Top" Width="1" Height="0" />
        <TextBox Height="72" Margin="0,0,0,0" Name="kontakt_name" Text="Name" VerticalAlignment="Top" GotFocus="kontakt_name_GotFocus" />
        <TextBox Height="72" Margin="0,72,0,0" Name="kontakt_email" Text="Email" VerticalAlignment="Top" GotFocus="kontakt_email_GotFocus" />
        <TextBox Height="72" Margin="0,144,0,0" Name="kontakt_telefon" Text="Telefon" VerticalAlignment="Top" GotFocus="kontakt_telefon_GotFocus" />
        <TextBox Height="196" Margin="0,216,0,0" Name="kontakt_nachricht" Text="Nachricht" VerticalAlignment="Top" GotFocus="kontakt_nachricht_GotFocus" />
        <Button Content="Absenden" Height="72" HorizontalAlignment="Left" Margin="6,408,0,0" Name="buttonsend" VerticalAlignment="Top" Width="438" Click="buttonsend_Click" />
    </Grid>
</Grid>

Kontakt.xaml中的网格必须显示在Mainpage.xaml中。但我不能参考它。

有人知道怎么做吗?我必须在Usercontrol中执行此操作,因为我也想在其他全景图中使用它。

1 个答案:

答案 0 :(得分:1)

<local:Kontakt />我想......