日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Windows8 Metro开发 (03) : AppBar控件之BottomAppBar

發布時間:2025/6/15 windows 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Windows8 Metro开发 (03) : AppBar控件之BottomAppBar 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
BottomAppBar 在介紹BottomAppBar之前還是先上張圖。
這次我們關注底部的AppBar.
上圖的AppBar分為左右2個部分。 左側是引用系統自帶的AppBar按鈕,右側是自定義的AppBar按鈕。其實寫法都一樣。
下面來看看布局文件 [plain]?view plaincopyprint?
  • <Page.BottomAppBar>??
  • ????????<!--?ApplicationBar?-->??
  • ????????<AppBar?x:Name="BottomAppbar">??
  • ????????????<Grid>??
  • ????????????????<Grid.RowDefinitions>??
  • ????????????????????<RowDefinition?Height="Auto"/>??
  • ????????????????????<RowDefinition?Height="Auto"/>??
  • ????????????????</Grid.RowDefinitions>??
  • ????????????????<StackPanel?x:Name="systemAppBarPanel"?Orientation="Horizontal">??
  • ????????????????????<Button?x:Name="SkipBackAppBarButton"?Style="{StaticResource?SkipBackAppBarButtonStyle}"?Click="OnSkipBackAppBarButtonCilcked"?/>??
  • ????????????????????<Button?x:Name="SkipAheadAppBarButton"?Style="{StaticResource?SkipAheadAppBarButtonStyle}"?Click="OnSkipAheadAppBarButtonCilcked"/>??
  • ????????????????????<Line?Width="5"?Stroke="White"?Stretch="Fill"?Y2="{Binding?ActualHeight,?ElementName=systemAppBarPanel,?Mode=OneWay}"/>??
  • ????????????????????<Button?x:Name="PlayAppBarButton"?Style="{StaticResource?PlayAppBarButtonStyle}"?Click="OnPlayAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="PauseAppBarButton"?Style="{StaticResource?PauseAppBarButtonStyle}"?Click="OnPauseAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="StopAppBarButton"?Style="{StaticResource?StopAppBarButtonStyle}"?Click="OnStopAppBarButtonCilcked"/>??
  • ????????????????</StackPanel>??
  • ????????????????<StackPanel?x:Name="customAppBarPanel"?Orientation="Horizontal"?HorizontalAlignment="Right">??
  • ????????????????????<Button?x:Name="LoveAppBarButton"?Style="{StaticResource?LoveAppBarButtonStyle}"?Click="OnLoveAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="CalcAppBarButton"??Style="{StaticResource?CalcAppBarButtonStyle}"?Click="OnCalcAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="TelAppBarButton"??Style="{StaticResource?TelAppBarButtonStyle}"?Click="OnTelAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="GoodAppBarButton"??Style="{StaticResource?GoodAppBarButtonStyle}"?Click="OnGoodAppBarButtonCilcked"/>??
  • ????????????????????<Button?x:Name="LaughAppBarButton"??Style="{StaticResource?LaughAppBarButtonStyle}"?Click="OnLaughAppBarButtonCilcked"/>??
  • ????????????????</StackPanel>??
  • ????????????</Grid>??
  • ????????</AppBar>??
  • ????</Page.BottomAppBar>??
  • 里面每一個Button的樣式都是不同的。這些樣式是什么呢?先來看看系統的樣式。 以SkipBackAppBarButtonStyle為例: [html]?view plaincopyprint?
  • <Style?x:Key="SkipBackAppBarButtonStyle"?TargetType="ButtonBase"?BasedOn="{StaticResource?AppBarButtonStyle}">??
  • ????<Setter?Property="AutomationProperties.AutomationId"?Value="SkipBackAppBarButton"/>??
  • ????<Setter?Property="AutomationProperties.Name"?Value="Skip?Back"/>??
  • ????<Setter?Property="Content"?Value="&#xE100;"/>??
  • </Style>??
  • SkipBackAppBarButton是以AppBarButtonStyle為基本樣式的一個AppBar按鈕,在這里我們只需注意最后2個Setter. <Setter Property="AutomationProperties.Name" Value="Skip Back"/>用來顯示按鈕下面的字串 <Setter Property="Content" Value="&#xE100;"/>?用來顯示按鈕中間圓圈里的字符串,再次強調這個不是“圖片”。 看到這里,你們也許知道了自定義按鈕該怎樣定義了。代碼還是貼下吧。 [html]?view plaincopyprint?
  • ????<Style?x:Key="LoveAppBarButtonStyle"?TargetType="ButtonBase"?BasedOn="{StaticResource?AppBarButtonStyle}">??
  • ????????<Setter?Property="AutomationProperties.AutomationId"?Value="LoveAppBarButton"/>??
  • ????????<Setter?Property="AutomationProperties.Name"?Value="愛心"/>??
  • ????????<Setter?Property="Content"?Value=""/>??
  • ????</Style>??
  • 每一個按鈕的事件都很簡單,就是彈出一個相應的對話框,這里就省略了。
    Snap模式處理 同TopAppBar一樣,BottomAppBar在Snap模式下的時候需要進行UI轉換。
    Snap模式后面會詳細介紹。這里先省略概念。
    如果不做處理,當你把程序拖到側邊欄時,你會發現此時BottomAppBar上面的按鈕只剩下了3個!并且按鈕上面的文字顯示不全。 因此我們需要對BottomAppBar的布局做下調整。當程序拖到側邊欄時,將左右兩側的按鈕分兩排顯示,縮小按鈕尺寸并且隱去按鈕下面文字。 不過系統并沒有定義這種按鈕的樣式,需要我們自己來實現: 創建文件AppBarPageStyle.xaml,在StandardStyles.xaml里找到AppBarButtonStyle,將其復制到AppBarPageStyle.xaml中,并更名為
    AppBarButtonSnapStyle,修改Template屬性。
    [plain]?view plaincopyprint?
  • <ControlTemplate?TargetType="ButtonBase">??
  • ???????????????????<Grid?x:Name="RootGrid"?Width="60"?Background="Transparent">??
  • ???????????????????????<StackPanel?VerticalAlignment="Top"?Margin="0,12,0,11">??
  • ???????????????????????????<Grid?Width="40"?Height="40"?Margin="0,0,0,5"?HorizontalAlignment="Center">??
  • ???????????????????????????????<TextBlock?x:Name="BackgroundGlyph"?Text=""?FontFamily="Segoe?UI?Symbol"?FontSize="53.333"?Margin="-4,-19,0,0"?Foreground="{StaticResource?AppBarItemBackgroundThemeBrush}"/>??
  • ???????????????????????????????<TextBlock?x:Name="OutlineGlyph"?Text=""?FontFamily="Segoe?UI?Symbol"?FontSize="53.333"?Margin="-4,-19,0,0"/>??
  • ???????????????????????????????<ContentPresenter?x:Name="Content"?HorizontalAlignment="Center"?Margin="-1,-1,0,0"?VerticalAlignment="Center"/>??
  • ???????????????????????????</Grid>??
  • ???????????????????????</StackPanel>??
  • ????????????????????...??
  • ???????????????????</Grid>??
  • ???????????????</ControlTemplate>??
  • 然后定義相對應的Snap AppBar按鈕 [plain]?view plaincopyprint?
  • <Style?x:Key="LoveAppBarButtonSnapStyle"?TargetType="ButtonBase"?BasedOn="{StaticResource?AppBarButtonSnapStyle}">??
  • ????<Setter?Property="Content"?Value=""/>??
  • </Style>??
  • 在AppBarPage頁面進入Snap模式的時候,如果在XAML里面注冊狀態監聽,程序會根據XAML代碼變換UI布局。 [plain]?view plaincopyprint?
  • <VisualState?x:Name="Snapped">??
  • ????????????????????<Storyboard>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="backButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?SnappedBackButtonStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="pageTitle"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?SnappedPageHeaderTextStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="customAppBarPanel"??Storyboard.TargetProperty="(Grid.Row)">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="1"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="customAppBarPanel"??Storyboard.TargetProperty="HorizontalAlignment">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="Left"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ??
  • ????????????????????????<!--appbar?button-->??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="SkipBackAppBarButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?SkipBackAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="SkipAheadAppBarButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?SkipAheadAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="PlayAppBarButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?PlayAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="PauseAppBarButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?PauseAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="StopAppBarButton"?Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?StopAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ?????????????????????????????????????????????????
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="LoveAppBarButton"??Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?LoveAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="CalcAppBarButton"??Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?CalcAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="TelAppBarButton"??Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?TelAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="GoodAppBarButton"??Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?GoodAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????????<ObjectAnimationUsingKeyFrames?Storyboard.TargetName="LaughAppBarButton"??Storyboard.TargetProperty="Style">??
  • ????????????????????????????<DiscreteObjectKeyFrame?KeyTime="0"?Value="{StaticResource?LaughAppBarButtonSnapStyle}"/>??
  • ????????????????????????</ObjectAnimationUsingKeyFrames>??
  • ????????????????????</Storyboard>??
  • ????????????????</VisualState>??
  • Snap模式下的BottomAppBar如下圖所示:

    注意: 1.別忘了在App.xaml中引用AppBarPageStyle.xaml
    [html]?view plaincopyprint?
  • <ResourceDictionary?Source="Common/StandardStyles.xaml"/>??
  • <ResourceDictionary?Source="Pages/Home/GlobalPageStyle.xaml"/>??
  • <ResourceDictionary?Source="Pages/Home/HomePageStyle.xaml"/>??
  • <ResourceDictionary?Source="Pages/01-AppBar/AppBarPageStyle.xaml"/>??
  • 2.AppBar控件的功能(應該是所有控件)需要符合微軟制定的規范,不能隨便制定。具體內容可參考MSDN。

    總結

    以上是生活随笔為你收集整理的Windows8 Metro开发 (03) : AppBar控件之BottomAppBar的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

    主站蜘蛛池模板: 成人久久久久久久 | 影音先锋波多野结衣 | 黑人干亚洲人 | 精品少妇久久 | 国产天天骚| 欧美极品jizzhd欧美 | 久久久久毛片 | 一区二区视频免费 | 蓝牛av| 在线不卡国产 | 国产一区视频在线 | 四虎成人精品在永久免费 | 亚洲激情黄色 | 中文字幕国产专区 | 黄色三级网站在线观看 | 九九热re| 久操新在线 | 国产精品一区二区三区四区五区 | 少妇无套内谢久久久久 | 色噜噜狠狠一区二区三区牛牛影视 | 7m精品福利视频导航 | 自拍偷拍亚洲天堂 | 人妻精品一区 | 国产在线久久久 | 女av在线| 欧美视频久久久 | 精品国产av色一区二区深夜久久 | 日韩精品中文字幕一区二区三区 | 日本久久一区 | 2018天天干天天操 | 精品三级av | 日老女人视频 | 精品一区二区三区无码视频 | 亚洲国产一区在线 | 一本色道久久综合亚洲二区三区 | 99久久久无码国产精品不卡 | 中文字幕日韩一级 | 亚洲一区亚洲二区 | 中文国产字幕 | 黄色裸体片 | 国产一区 在线播放 | www.jizzjizz.com| a毛片毛片av永久免费 | 天堂a在线 | 亚欧成人精品一区二区 | 翔田千里一区 | 日韩大片在线观看 | 一区二区三区四区五区在线视频 | 反差在线观看免费版全集完整版 | 国产乱淫av片免费看 | 精品国产乱码一区二区三区99 | 奇米四色777 | 男人操女人免费 | 亚洲人一区二区三区 | 国产一线av | 成年人在线观看视频网站 | 大尺度叫床戏做爰视频 | 自拍偷拍日韩精品 | 天天干天天综合 | 欧美日韩在线视频 | 国模福利视频 | 国产精品麻豆果冻传媒在线播放 | 免费看av的网址 | 中文字幕亚洲在线观看 | 久久人成| 青青草原av | 黄色成人在线 | 激情二区| 91久久免费 | 国产三区精品 | 欧美一区日韩一区 | 色综合五月婷婷 | 国产一卡二卡在线播放 | 欧美日本三级 | 色爽交 | 欧美激情免费视频 | 波多野结衣在线观看视频 | 国产特级黄色片 | 亚洲人成电影网 | 国产精品视频一区二区在线观看 | 日本高清视频www夜色资源 | 日本不卡在线观看 | 91精品国产99久久久久久 | 日本久久久久 | 亚洲一区二区三区在线视频 | www.日日操 | 女人天堂av| 免费观看av的网站 | av免费网址在线观看 | 日本免费在线一区 | 91jk制服白丝超短裙大长腿 | 日韩欧美中文在线 | 99热影院| 日韩在线激情视频 | 精品日日夜夜 | 精品中文一区二区三区 | 男人天堂v | 国产不卡精品视频 | 中国黄色网页 |