Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.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 Phone 7滑动菜单_Windows Phone 7_Slidingmenu - Fatal编程技术网

Windows phone 7 Windows Phone 7滑动菜单

Windows phone 7 Windows Phone 7滑动菜单,windows-phone-7,slidingmenu,Windows Phone 7,Slidingmenu,我正在windows phone 7中开发一个应用程序。在这个应用程序中,我已经完成了30多个屏幕。现在我想在所有页面中添加滑动菜单 请告诉我在所有页面中添加滑动菜单的想法 我试过WindowsPhoneControl。我用listbox创建了一个菜单,并尝试添加所有页面 用户控制页:- <UserControl x:Class="NewExample.SlidingMenu" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/

我正在windows phone 7中开发一个应用程序。在这个应用程序中,我已经完成了30多个屏幕。现在我想在所有页面中添加滑动菜单

请告诉我在所有页面中添加滑动菜单的想法

我试过WindowsPhoneControl。我用listbox创建了一个菜单,并尝试添加所有页面

用户控制页:-

<UserControl x:Class="NewExample.SlidingMenu"
    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="768" d:DesignWidth="400">
      <Grid x:Name="LayoutRoot" Background="#FFB4B4B4">
            <Button Command="{Binding testButton1}" Content="Test Button 1" Height="72" HorizontalAlignment="Left" Margin="12,10,0,0" Name="button1" VerticalAlignment="Top" Width="376" />
            <Button Command="{Binding testButton2}" Content="Test Button 2" Height="72" HorizontalAlignment="Left" Margin="12,72,0,0" Name="button2" VerticalAlignment="Top" Width="376" />
            <Button Command="{Binding testButton3}" Content="Test Button 3" Height="72" HorizontalAlignment="Left" Margin="12,132,0,0" Name="button3" VerticalAlignment="Top" Width="376" />
            <Button Command="{Binding testButton4}" Content="Test Button 4" Height="72" HorizontalAlignment="Left" Margin="12,196,0,0" Name="button4" VerticalAlignment="Top" Width="376" />
        </Grid>
    </UserControl>

第页:-

 <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--ContentPanel -  place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="{Binding gridMargin}">

            <Button Command="{Binding slideButton}" Content="Slide" Height="70" Name="slideButton" Width="160" HorizontalAlignment="Left" VerticalAlignment="Top" />
            <ScrollViewer Margin="0,80,0,100">
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="Index Page 3" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Stretch" />
                    <Button Width="476" Command="{Binding getPageStackButton}" Content="Get Pages From PageStack" Height="72" HorizontalAlignment="Left" Margin="5,0,0,0" Name="button12" VerticalAlignment="Bottom" />
                    <Button Command="{Binding messageBoxExampleButton}" Content="Message Box Example" Height="72" Name="button1" Width="476" />
                    <Button Command="{Binding orderDetailButton}" Content="Order Detail" Height="72" Name="button3" Width="476" />
                    <Button Command="{Binding customMessageButton}" Content="Custom Message Box" Height="72" Name="button2" Width="476" />

                </StackPanel>
            </ScrollViewer>
            <local:BottomTabBar Margin="0,660,0,0"/>                
            <Grid x:Name="SettingsPane" Width="400"
             Margin="{Binding slideMargin}"
             Grid.Row="0">
                <local:SlidingMenu Width="400" Margin="0,0,0,0" />
            </Grid> 
        </Grid>
    </Grid>

当我单击页面中的滑块按钮时,我只需更改滑块和页面的边距


但它不像滑动菜单那样工作。请告诉我其他的想法。

这可能不是最好的方法,但非常简单

如果希望菜单从底部滑入,请将XAML更改为类似的内容:

<NewExample:SlidingMenu x:Name="ucMain"Height="500" VerticalAlignment="Bottom" Margin="0,0,0,-500"/>
代码的其余部分:

private void SlideIn()
    {
        DispatcherTimer timerMenuIn = new DispatcherTimer();
        timerMenuIn.Interval = new TimeSpan(0, 0, 0, 0, 1);
        timerMenuIn.Tick += timerMenuIn_Tick;
        timerMenuIn.Start();
    }

    void timerMenuIn_Tick(object sender, EventArgs e)
    {
        int speed = 7;
        if (ucMain.Margin.Bottom >= -speed)
        {
            ucMain.Margin = new Thickness(
            ucMain.Margin.Left,
            ucMain.Margin.Top,
            ucMain.Margin.Right, 0);
            ((DispatcherTimer)sender).Stop();
        }
        else
        {
            ucMain.Margin = new Thickness(
            ucMain.Margin.Left,
            ucMain.Margin.Top,
            ucMain.Margin.Right,
            ucMain.Margin.Bottom + speed);
        }
    }
通过更改其他边距值,可以轻松更改方向。希望这是您正在寻找的内容

您可以下载。并按照“通过代码使用页面转换”部分下的说明进行操作,您要阅读的部分位于网页的一半

private void SlideIn()
    {
        DispatcherTimer timerMenuIn = new DispatcherTimer();
        timerMenuIn.Interval = new TimeSpan(0, 0, 0, 0, 1);
        timerMenuIn.Tick += timerMenuIn_Tick;
        timerMenuIn.Start();
    }

    void timerMenuIn_Tick(object sender, EventArgs e)
    {
        int speed = 7;
        if (ucMain.Margin.Bottom >= -speed)
        {
            ucMain.Margin = new Thickness(
            ucMain.Margin.Left,
            ucMain.Margin.Top,
            ucMain.Margin.Right, 0);
            ((DispatcherTimer)sender).Stop();
        }
        else
        {
            ucMain.Margin = new Thickness(
            ucMain.Margin.Left,
            ucMain.Margin.Top,
            ucMain.Margin.Right,
            ucMain.Margin.Bottom + speed);
        }
    }