Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
windows phone 7中带有注销按钮的标题_Windows_Silverlight_Windows Phone 7_Header - Fatal编程技术网

windows phone 7中带有注销按钮的标题

windows phone 7中带有注销按钮的标题,windows,silverlight,windows-phone-7,header,Windows,Silverlight,Windows Phone 7,Header,我不熟悉windows phone开发 我需要带有“注销”按钮的自定义标题,然后在每页上使用它。我如何才能做到这一点?首先,在应用程序的每页标题中都有一个“注销”按钮不是一个好主意。我建议您使用ApplicationBar,并在其中添加注销MenuItem。其主要思想是注销操作不经常使用,因此它是隐藏的。并将注销逻辑添加到basePhoneApplicationPageclass或baseViewModelclass。 如果使用ApplicationBar不适合您,您可以使用UserContro

我不熟悉windows phone开发


我需要带有“注销”按钮的自定义标题,然后在每页上使用它。我如何才能做到这一点?

首先,在应用程序的每页标题中都有一个“注销”按钮不是一个好主意。我建议您使用
ApplicationBar
,并在其中添加注销
MenuItem
。其主要思想是注销操作不经常使用,因此它是隐藏的。并将注销逻辑添加到base
PhoneApplicationPage
class或base
ViewModel
class。 如果使用
ApplicationBar
不适合您,您可以使用
UserControl
并将其添加到每个应用程序页面。 标题
UserControl

<UserControl x:Class="PhoneApp3.LogoutUserControl"
    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: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" Background="{StaticResource PhoneChromeBrush}">
        <StackPanel>
            <Image Source="/Images/Header.jpg"/>
            <Button Click="Logout" Content="Logout"/>
        </StackPanel>
    </Grid>
</UserControl>

你的主页看起来像

   <phone:PhoneApplicationPage
    x:Class="PhoneApp3.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:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:userControls="clr-namespace:PhoneApp3"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
            <userControls:LogoutUserControl Grid.Row="0" x:Name="HeaderControl"/>
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>