資源描述:
《Windows8開(kāi)發(fā)5-Windows 8 App AppBar》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、TravelJourney-AppBar1.1添加AppBar這里,我們選擇在ItemDetailsPage頁(yè)面添加AppBar,代碼如下:2、Name="RightPanel"Orientation="Horizontal"Grid.Column="1"HorizontalAlignment="Right">
1.2實(shí)現(xiàn)AppBar上的按鈕(PINtoStart)在ItemDetailsPage的后臺(tái)文件中添加代碼:voidInit(){pinToAppBar.Click+=pinToAppBar
3、_Click;pageRoot.BottomAppBar.Opened+=BottomAppBar_Opened;}voidBottomAppBar_Opened(objectsender,objecte){ToggleAppBarButton(!SecondaryTile.Exists(((SampleDataItem)this.flipView.SelectedItem).UniqueId));}RectGetElementRect(FrameworkElementelement){FrameworkEl
4、ementsender=(FrameworkElement)pinToAppBar;Windows.UI.Xaml.Media.GeneralTransformbuttonTransform=sender.TransformToVisual(null);Windows.Foundation.Pointpoint=buttonTransform.TransformPoint(newPoint());Windows.Foundation.Rectrect=newRect(point,newSize(element
5、.ActualWidth,element.ActualHeight));returnrect;}asyncvoidpinToAppBar_Click(objectsender,RoutedEventArgse){varitem=(SampleDataItem)this.flipView.SelectedItem;varuri=newUri(item.TileImagePath.AbsoluteUri);if(SecondaryTile.Exists(item.UniqueId)){SecondaryTiles
6、econdaryTile=newSecondaryTile(item.UniqueId);boolisUnpinned=awaitsecondaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender),Windows.UI.Popups.Placement.Above);ToggleAppBarButton(isUnpinned);}else{SecondaryTilesecondaryTile=newSeco
7、ndaryTile(item.UniqueId,item.UniqueId,item.UniqueId,item.UniqueId,TileOptions.None,uri);boolisPinned=awaitsecondaryTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement)sender),Windows.UI.Popups.Placement.Above);ToggleAppBarButton(!isPinned);
8、}pageRoot.BottomAppBar.IsOpen=false;}privatevoidToggleAppBarButton(boolshowPinButton){if(pinToAppBar!=null)pinToAppBar.Style=(showPinButton)?(Application.Current.Resources["PinAppBarButtonStyle"]asStyl