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(); } } }