Windows 8 Store Apps學習(2) 按鈕控制項

來源:互聯網
上載者:User

Button, HyperlinkButton, RepeatButton

介紹

重新想象 Windows 8 Store Apps 之按鈕控制項

Button - 按鈕控制項

HyperlinkButton - 超鏈按鈕

RepeatButton - 按住後會重複執行單擊操作的按鈕

ToggleButton - 可切換狀態的按鈕

RadioButton - 單選框控制項

CheckBox - 複選框控制項

ToggleSwitch - 狀態切換控制項

樣本

1、Button 的 Demo

ButtonDemo.xaml.cs

/*    * Button - 按鈕控制項    */       using System;   using Windows.UI.Popups;   using Windows.UI.Xaml;   using Windows.UI.Xaml.Controls;   using Windows.UI.Xaml.Navigation;          namespace XamlDemo.Controls   {       public sealed partial class ButtonDemo : Page       {           public ButtonDemo()           {               this.InitializeComponent();           }                  protected override void OnNavigatedTo          (NavigationEventArgs e)           {               /*                * Button - 按鈕控制項,其全部功能是通過其基類 ButtonBase 提供的             *     ClickMode - 引發 Click 事件的模式:ClickMode.Release(預設值), ClickMode.Press, ClickMode.Hover                *     IsPointerOver - 裝置指標(滑鼠或手指等)是否在按鈕上                *     IsPressed - 當前按鈕是否處於按下的狀態                *     Command 和 CommandParameter 等寫到 MVVM 的時候再詳細寫                */                   Button btn = new Button();               btn.Content = "我是按鈕";               btn.ClickMode = ClickMode.Hover;               btn.Click += btn_Click;               root.Children.Add(btn);           }                  async void btn_Click(object sender,           RoutedEventArgs e)           {               await new MessageDialog("觸發了按鈕的           Click 事件").ShowAsync();           }       }   }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.