1

我在我的应用程序上的导航坏了,这里是 .cs http://pastebin.com/VpzAbTGH ,这里是 xaml http://pastebin.com/pNSNqaRM

我已经注释掉了很多我现在没有使用的代码,因为我正在缓慢地更改应用程序的 gui 并慢慢地将它带过来。如果它有帮助,我愿意分享我的源代码来解决这个问题,谢谢。 CS

// ------------------------------------------------------------------------
// ========================================================================
// THIS CODE AND INFORMATION ARE GENERATED BY AUTOMATIC CODE GENERATOR
// ========================================================================
// Template:   PageCS.tt
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Entities=WPAppStudio.Entities;
using Ioc=WPAppStudio.Ioc;
using IServices=WPAppStudio.Services.Interfaces;
using IViewModels=WPAppStudio.ViewModel.Interfaces;
using Localization=WPAppStudio.Localization;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using MyToolkit.Paging;
using Repositories=WPAppStudio.Repositories;
using WPAppStudio;
using System.Resources;
using System.Windows.Media.Animation;
using System.Windows.Input;


namespace WPAppStudio.View
{
    /// <summary>
    /// Phone application page for MainNews_News.
    /// </summary>
    [CompilerGenerated]
    [GeneratedCode("Radarc", "4.0")]
    public partial class MainNews_News : PhoneApplicationPage
    {       
        /// <summary>
        /// Initializes the phone application page for MainNews_News and all its components.
        /// </summary>
        public MainNews_News()
        {
            InitializeComponent();
            VisualStateManager.GoToState(this, "Normal", false);
            if (Resources.Contains("PanoramaMainNews_News0AppBar"))
                PhonePage.SetApplicationBar(this, Resources["PanoramaMainNews_News0AppBar"] as BindableApplicationBar); 

        }

        private void panoramaMainNews_News_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            InitializeAppBarpanoramaMainNews_News(PanoramaMainNews_News.SelectedItem as PivotItem);
        }

        private void InitializeAppBarpanoramaMainNews_News(PivotItem panoramaItem)        
        {
            if (Resources.Contains(panoramaItem.Name + "AppBar"))
            {
                PhonePage.SetApplicationBar(this, Resources[panoramaItem.Name + "AppBar"] as BindableApplicationBar);            
                ApplicationBar.IsVisible = true;
            }
            else if(ApplicationBar != null)
                ApplicationBar.IsVisible = false;
        }
        private void OpenClose_Left(object sender, RoutedEventArgs e)
        {
            var left = Canvas.GetLeft(LayoutRoot);
            if (left > -100)
            {
                ApplicationBar.IsVisible = true;
                MoveViewWindow(-420);
            }
            else
            {
                ApplicationBar.IsVisible = false;
                MoveViewWindow(0);
            }
        }
        private void OpenClose_Right(object sender, RoutedEventArgs e)
        {
            var left = Canvas.GetLeft(LayoutRoot);
            if (left > -520)
            {
                ApplicationBar.IsVisible = false;
                MoveViewWindow(-840);
            }
            else
            {
                ApplicationBar.IsVisible = true;
                MoveViewWindow(-420);

            }
        }

        void MoveViewWindow(double left)
        {
            _viewMoved = true;
            if (left == -420)
                ApplicationBar.IsVisible = true;
            else
                ApplicationBar.IsVisible = false;
            ((Storyboard)canvas.Resources["moveAnimation"]).SkipToFill();
            ((DoubleAnimation)((Storyboard)canvas.Resources["moveAnimation"]).Children[0]).To = left;
            ((Storyboard)canvas.Resources["moveAnimation"]).Begin();
        }

        private void canvas_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
        {
            if (e.DeltaManipulation.Translation.X != 0)
                Canvas.SetLeft(LayoutRoot, Math.Min(Math.Max(-840, Canvas.GetLeft(LayoutRoot) + e.DeltaManipulation.Translation.X), 0));
        }

        double initialPosition;
        bool _viewMoved = false;
        private void canvas_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
        {
            _viewMoved = false;
            initialPosition = Canvas.GetLeft(LayoutRoot);
        }

        private void canvas_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
        {
            var left = Canvas.GetLeft(LayoutRoot);
            if (_viewMoved)
                return;
            if (Math.Abs(initialPosition - left) < 100)
            {
                //bouncing back
                MoveViewWindow(initialPosition);
                return;
            }
            //change of state
            if (initialPosition - left > 0)
            {
                //slide to the left
                if (initialPosition > -420)
                    MoveViewWindow(-420);
                else
                    MoveViewWindow(-840);
            }
            else
            {
                //slide to the right
                if (initialPosition < -420)
                    MoveViewWindow(-420);
                else
                    MoveViewWindow(0);
            }

        }
        /// <summary>
        /// Called when the page becomes the active page.
        /// </summary>
        /// <param name="e">Contains information about the navigation done.</param>
        protected override  void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            MainNews_NewsListControl.SelectedItem = null;

        //    GamesNews_GamesNewsfeedListControl.SelectedItem = null;

        //    SoftwareNews_SoftwareNewsfeedListControl.SelectedItem = null;

        //    MenuSection_MenuMenuControl.SelectedItem = null;
        }

        private void PanoramaMainNews_News_Loaded(object sender, RoutedEventArgs e)
        {

        }

    }
}

这是xaml文件

<phone:PhoneApplicationPage 
    x:Class="WPAppStudio.View.MainNews_News"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ctl="clr-namespace:WPAppStudio.Controls"
    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:toolkit="clr-   namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:mytoolkit="clr-namespace:MyToolkit.Controls;assembly=MyToolkit.Extended"
    xmlns:mytoolkitpaging="clr-namespace:MyToolkit.Paging;assembly=MyToolkit.Extended"

    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource CustomApplicationTextBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    DataContext="{Binding Path=MainNews_NewsViewModel, Source={StaticResource ViewModelLocator}}">

<Canvas x:Name="canvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="800" Background="Black" ManipulationStarted="canvas_ManipulationStarted" ManipulationDelta="canvas_ManipulationDelta" ManipulationCompleted="canvas_ManipulationCompleted">
        <Canvas.Resources>
            <Storyboard x:Name="moveAnimation">
                <DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True" />
            </Storyboard>
        </Canvas.Resources>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="CommonStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.3">
                        <VisualTransition.GeneratedEasingFunction>
                            <QuinticEase EasingMode="EaseInOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Normal">
                    <Storyboard>
                        <DoubleAnimation Duration="0:0:0.2" To="-420" Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="LeftMenuOpened">
                    <Storyboard>
                        <DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="RightMenuOpened">
                    <Storyboard>
                        <DoubleAnimation Duration="0:0:0.2" To="-840" Storyboard.TargetProperty="(Canvas.Left)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Canvas  CacheMode="BitmapCache" x:Name="LayoutRoot" Width="1320"  VerticalAlignment="Stretch" Background="Transparent" Canvas.Left="-420" Height="768">
            <!--<Grid.ColumnDefinitions>
                <ColumnDefinition Width="420"/>
                <ColumnDefinition Width="480"/>
                <ColumnDefinition Width="420"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>-->
            <Border Width="420"  CacheMode="BitmapCache" Background="#222e3e" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="{Binding ActualHeight, ElementName=canvas}"/>
            <Border Width="420" Margin="900,0,0,0" CacheMode="BitmapCache" Background="#222e3e" Grid.Column="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="{Binding ActualHeight, ElementName=canvas}"/>
            <Grid x:Name="grdCommands" Margin="420,0,0,0" CacheMode="BitmapCache" Grid.Column="1" Background="#FFCFD4E2" Height="{Binding ActualHeight, ElementName=canvas}" Width="480" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="59"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"  Background="#1b4f77">
                    <Image  Source="/neologo_Images/Image.png" HorizontalAlignment="Stretch" Margin="-10,-51,10,-62"/>
                    <Button  Click="OpenClose_Left" Content="" HorizontalAlignment="Left" VerticalAlignment="Top" Width="71" Height="62"/>
                    <Button  Click="OpenClose_Right" Content="" HorizontalAlignment="Right" VerticalAlignment="Top" Width="70" Height="62" Margin="0,0,10,0"/>
                </Grid>
                <Border Grid.Row="1" Background="#FF31363E"/>
                <phone:Pivot x:Name="PanoramaMainNews_News" Grid.Row="1" Foreground="{StaticResource CustomApplicationTextBrush}" Background="{StaticResource CustomApplicationBackgroundBrush}" SelectionChanged="panoramaMainNews_News_SelectionChanged" Loaded="PanoramaMainNews_News_Loaded" Margin="0,0,0,16">

                    <phone:Pivot.Title>




                                <ProgressBar IsIndeterminate="True"  Visibility="{Binding LoadingMainNews_NewsListControlCollection, Converter={StaticResource VisibilityConverter}}" />



                    </phone:Pivot.Title>
                    <phone:PivotItem x:Name="PanoramaMainNews_News0" Margin="0,0,0,25">
                        <phone:PivotItem.Header>
                            <StackPanel Orientation="Horizontal" Margin="0,7,0,0">
                                <TextBlock Text="spotlight        " Margin="-10,0,0,0" FontWeight="Normal" FontFamily="Segoe WP"/>
                            </StackPanel>
                        </phone:PivotItem.Header>
                        <Grid>
                            <ctl:LongListSelector x:Name="MainNews_NewsListControl" 
                    ItemsSource="{Binding MainNews_NewsListControlCollection}"
                    SelectedItem="{Binding SelectedMainNews_NewsListControlCollection, Mode=TwoWay}"
                    PagingEnabled="False"
                    RefreshCommand="{Binding RefreshMainNews_NewsListControlCollection}"
                    >
                                <ctl:LongListSelector.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Margin="30" toolkit:TiltEffect.IsTiltEnabled="True" Background="Black">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition Height="Auto"/>
                                                <RowDefinition MaxHeight="80"/>
                                            </Grid.RowDefinitions>
                                            <Image Source="{Binding ImageUrl, TargetNullValue={StaticResource DefaultNoImageValue}}" VerticalAlignment="Top" Stretch="UniformToFill" MaxHeight="250" Margin="20,20,20,0"/>
                                            <TextBlock TextWrapping="Wrap" FontSize="32" Foreground="{StaticResource CustomApplicationTextBrush}" 
                                            Text="{Binding Title, Converter={StaticResource SanitizeString}}" Margin="20,0" Grid.Row="1"/>
                                            <TextBlock TextWrapping="Wrap" FontSize="18" Foreground="{StaticResource CustomApplicationTextBrush}"
                                        TextTrimming="WordEllipsis" Text="{Binding Summary, Converter={StaticResource SanitizeString}}" Height="75" Margin="20,0,0,20" Grid.Row="2" VerticalAlignment="Top"/>
                                        </Grid>
                                    </DataTemplate>
                                </ctl:LongListSelector.ItemTemplate>
                            </ctl:LongListSelector>
                        </Grid>
                    </phone:PivotItem>
                </phone:Pivot>
            </Grid>
            <HyperlinkButton Content="HyperlinkButton" Canvas.Left="947" Canvas.Top="41"/>
        </Canvas>
    </Canvas>

这是一张图片

4

0 回答 0