Windows Phone 選擇按鈕並且知道你選了什麼

  <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <Button Grid.Row="0" Margin="0,2,0,15" Content="有提示的按鈕" Click="Button_Click"/>
            <StackPanel Grid.Row="1">
                <Button Content="有提示的按鈕" Margin="0,2,0,15" Click="Button_Click_1"/>
                <TextBlock Name="text" FontSize="32"/>
            </StackPanel>
        </Grid>
  private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("沒有提示的按鈕");
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show("有按鈕的提示", "提示按鈕", MessageBoxButton.OKCancel);
            switch(res){
                case MessageBoxResult.Cancel:
                this.text.Text = "你取消了按鈕";
                break;
                case MessageBoxResult.OK:
                this.text.Text = "你點擊了按鈕";
                break;

            }
        }


發佈了62 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章