zoukankan      html  css  js  c++  java
  • WPF 学习笔记(十一)

    (1)子窗口界面设置

    <Window x:Class="WpfApplication1.InputWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="输入窗口" Height="101" Width="294" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
        <Grid>
            <Button Content="确定" Height="23" HorizontalAlignment="Right" Margin="0,35,8,0" Name="btnOk" VerticalAlignment="Top" Width="75" Click="btnOk_Click" />
            <Button Content="取消" Height="23" HorizontalAlignment="Left" Margin="114,35,0,0" Name="btnCancel" VerticalAlignment="Top" Width="75" Click="btnCancel_Click" />
            <TextBox Height="32" HorizontalAlignment="Left" Name="txtUserName" VerticalAlignment="Top" Width="278" />
        </Grid>
    </Window>

    (2)子窗口属性设置

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// InputWindow.xaml 的交互逻辑
        /// </summary>
        public partial class InputWindow : Window
        {
            public string InputValue { set; get; }
            public InputWindow()
            {
                InitializeComponent();
            }
    
            private void btnCancel_Click(object sender, RoutedEventArgs e)
            {            
                DialogResult = false; //如果窗口是用ShowDialog打开的,则给dialogresult赋值就会自动关闭窗口,并把结果值返回
            }
    
            private void btnOk_Click(object sender, RoutedEventArgs e)
            {
                InputValue = txtUserName.Text;
                DialogResult = true; //如果窗口是用ShowDialog打开的,则给dialogresult赋值就会自动关闭窗口,并把结果值返回
            }
        }
    }

    (3)主界面设计

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void btnOpen_Click(object sender, RoutedEventArgs e)
            {
                InputWindow inputWin = new InputWindow();
                bool? b = inputWin.ShowDialog();
    
                if (b == null)
                {
                    MessageBox.Show("没设置?");
                }else if(b == true){
                    MessageBox.Show("确定"+inputWin.txtUserName);
                }else{
                    MessageBox.Show("取消");
                }
            }
        }
    }
  • 相关阅读:
    CxfInvokeUtil
    springboot+webservice(cxf和jax-ws两种方式)
    cxf 工具类转载
    Java动态调用Webservice,不生成客户端,基于soapUI
    转载 CXF动态调用webservice
    spring gzip 静态压缩优化
    sql server2008登录出错怎么整
    配置opencv时计算机显示丢失opencv_world300d.dll如何解决
    随记
    多态与异常处理(课后作业)
  • 原文地址:https://www.cnblogs.com/dLong/p/9581692.html
Copyright © 2011-2022 走看看