zoukankan      html  css  js  c++  java
  • Silverlight中子窗体的保存和取消

    子窗体的cs文件:

    public partial class ChildWindow1 : ChildWindow
    {
      public ChildWindow1()
      {
        InitializeComponent();
      }
      public void UrlMessage(string str)
      {
        switch(str)
        {
        case "提交":
        this.DialogResult = true;
        break;
        case "取消":
        this.DialogResult = false;
        break; 
        }

      }
    }

    使用的时候

    ChildWindow1 childwindow1 = new ChildWindow1();
    childwindow1.Width = 640;
    childwindow1.Height = 408;
    childwindow1.Title = "用户信息";
    childwindow1.Content = new EditUserInfo();
    childwindow1.Show();

    void btnCancel_Click(object sender, RoutedEventArgs e)
    {
      try
      {
        ChildWindow1 childwindow1 = this.FindParentByType<ChildWindow1>();
        childwindow1.UrlMessage("取消");
      }
      catch (Exception)
      {

      }
    }

    public static class TreeHelper
    {
      public static T FindParentByType<T>(this DependencyObject child) where T : DependencyObject
      {
        Type type = typeof(T);
        DependencyObject parent = VisualTreeHelper.GetParent(child);

        if (parent == null)
        {
          return null;
        }
        else if (parent.GetType() == type)
        {
          return parent as T;
        }
        else
        {
          return parent.FindParentByType<T>();
        }
      }
    }

  • 相关阅读:
    linux2.6.24.3下移植SD/MMC到S3C2440上的全历程
    设置装备布置了下双表示器
    Virtual Box 1.5.0 - 实用的“无缝窗口”
    oracle DB LINK 运用
    Linux下的tidy安置
    Linux效劳器装机安全疾速进阶指南(2)
    Linux下历程间通信
    Firefox 3 CSS Hack
    Linux下的搜刮东西find根基用法
    Linux效能器装机平安快速进阶指南(3)
  • 原文地址:https://www.cnblogs.com/caok168/p/2561203.html
Copyright © 2011-2022 走看看