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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章