2012-12-14 150 views
0

如何使用Windows 8仿真器进入捕捉状态?我收到来自Windows 8商店的通知,说明我的软件仅在快照模式下崩溃。有谁知道为什么切换模式会导致我的软件崩溃?这里是我的代码背后:Windows 8仿真器捕捉状态

namespace MenuFinderWin8.Pages 
{ 

public sealed partial class RestaurantHomePage : MenuFinderWin8.Common.LayoutAwarePage 
{ 
    MenuFinderAppServiceClient serviceClient; 
    RestaurantRepository repository; 
    Geolocator _geolocator = null; 
    ObservableCollection<RestaurantLocation> items; 

    public RestaurantHomePage() 
    { 
     this.InitializeComponent(); 
     if (!Network.IsNetwork()) 
     { 
      return; 
     } 
     repository = new RestaurantRepository(); 
     serviceClient = new MenuFinderAppServiceClient(); 
     _geolocator = new Geolocator(); 
     items = new ObservableCollection<RestaurantLocation>(); 
     BindData(); 
    } 

    void btnAbout_Click(object sender, RoutedEventArgs e) 
    { 
     Flyout f = new Flyout(); 
     LayoutRoot.Children.Add(f.HostPopup); // add this to some existing control in your view like the root visual 

     // remove the parenting during the Closed event on the Flyout 
     f.Closed += (s, a) => 
     { 
      LayoutRoot.Children.Remove(f.HostPopup); 
     }; 

     // Flyout is a ContentControl so set your content within it. 
     SupportUserControl userControl = new SupportUserControl(); 
     userControl.UserControlFrame = this.Frame; 
     f.Content = userControl; 
     f.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 223, 58, 51)); 
     f.Width = 200; 
     f.Height = 200; 
     f.Placement = PlacementMode.Top; 
     f.PlacementTarget = sender as Button; // this is an UI element (usually the sender) 

     f.IsOpen = true; 
    } 

    void btnSearch_Click(object sender, RoutedEventArgs e) 
    { 
     Flyout f = new Flyout(); 
     LayoutRoot.Children.Add(f.HostPopup); // add this to some existing control in your view like the root visual 

     // remove the parenting during the Closed event on the Flyout 
     f.Closed += (s, a) => 
     { 
      LayoutRoot.Children.Remove(f.HostPopup); 
     }; 

     // Flyout is a ContentControl so set your content within it. 
     RestaurantSearchUserControl userControl = new RestaurantSearchUserControl(); 
     userControl.UserControlFrame = this.Frame; 
     f.Content = userControl; 
     f.BorderBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 223, 58, 51)); 
     f.Width = 600; 
     f.Height = 400; 
     f.Placement = PlacementMode.Top; 
     f.PlacementTarget = sender as Button; // this is an UI element (usually the sender) 

     f.IsOpen = true; 

    } 

    void btnViewFavorites_Click(object sender, RoutedEventArgs e) 
    { 
     App.DataMode = Mode.SavedRestaurant; 
     if (repository.GetGroupedRestaurantsFromDatabase().Count() == 0) 
     { 
      MessageDialog messageDialog = new MessageDialog("You have no saved restaurants.", "No Restaurants"); 
      messageDialog.ShowAsync(); 
     } 
     else 
     { 
      this.Frame.Navigate(typeof(RestaurantSearchDetails)); 
     } 
    } 

    private async void BindData() 
    { 
     try 
     { 
      items = await serviceClient.GetSpecialRestaurantsAsync(); 



      List<RestaurantLocation> myFavs = repository.GetRestaurantLocations(); 
      foreach (var a in myFavs) 
      { 
       items.Add(a); 
      } 

      this.DefaultViewModel["Items"] = items; 
     } 
     catch (Exception) 
     { 
      MessageDialog messsageDialog = new MessageDialog("The MenuFinder service is unavailable at this time or you have lost your internet connection. If your internet is OK, please check back later.", "Unavailable"); 
      messsageDialog.ShowAsync(); 
      btnAbout.IsEnabled = false; 
      btnSearch.IsEnabled = false; 
      btnViewFavorites.IsEnabled = false; 
     } 
     myBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed; 
    } 


    /// <summary> 
    /// Populates the page with content passed during navigation. Any saved state is also 
    /// provided when recreating a page from a prior session. 
    /// </summary> 
    /// <param name="navigationParameter">The parameter value passed to 
    /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. 
    /// </param> 
    /// <param name="pageState">A dictionary of state preserved by this page during an earlier 
    /// session. This will be null the first time a page is visited.</param> 
    protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) 
    { 
     // TODO: Assign a bindable collection of items to this.DefaultViewModel["Items"] 
    } 

    private void itemGridView_ItemClick_1(object sender, ItemClickEventArgs e) 
    { 
     App.CurrentRestaurantLocation = e.ClickedItem as RestaurantLocation; 
     if (App.CurrentRestaurantLocation != null) 
     { 
      Order order = repository.AddOrder(DateTime.Now, string.Empty, App.CurrentRestaurantLocation.ID); 
      App.CurrentOrder = order; 
      App.DataMode = Mode.Menu; 
      this.Frame.Navigate(typeof(RootViewPage)); 
     } 
    } 
} 

}

回答

1

错误可能是你的XAML,比后面的代码更。如果您使用了模板但删除或修改了其中一个元素的名称,则引用该元素的KeyFrame无法获取该元素,因此引发异常。

搜索在XAML中这样的事情

<VisualState x:Name="Snapped"> 
       <Storyboard>... 

,并删除ObjectAnimationUsingKeyFrames标签来Storyboard.TargetName属性等于一个不存在的元素。

关于如何在模拟器上输入Snapped模式,与PC相同,只需从顶部抓取应用程序,并在按住喀哒声的同时将其滑动到一侧。

2

回应“如何使用Windows 8模拟器进入捕捉状态?” - 我发现在模拟器中捕捉最简单的方法是使用键盘快捷键,这是Windows键+。 (期)。