使用System.Windows.Controls作为参数而不是for [英] use a System.Windows.Controls as a parameter instead a for

查看:172
本文介绍了使用System.Windows.Controls作为参数而不是for的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在C#中有2个项目:一个WPF应用程序和一个旧的空c#项目。在最后一个我有一个验证表单的方法

Hi ,
I have 2 projects in C#: a WPF app and a old empty c# project. In the last one I have a method that validates Forms

public void SetParentUserConrtol(Form parent, uint id)
    {
        // Set the data
        _parentUserControl = parentUserControl;
        _parentID = id;

        // Check valid
        if (!IsValid())
            DisableParent();
    }



我想在我的WPF中使用这个项目,这基本上意味着:我希望我的旧空c#项目能够接收一个System.Windows .UserControl作为参数(或WPF窗口)而不是Form。





我无法添加System.Windows.Controls作为参考。我怎么解决这个问题?这个c#空项目是我的wpf和加密狗代码之间的桥梁,因为我坚持这个。


I want to use this project with my WPF , which basically means : I want that my old empty c# project be able to receive a System.Windows.UserControl as a parameter( or a WPF window) instead a Form.


I am not able to add System.Windows.Controls asa reference. How can I solve this? This c# empty project is the bridge between my wpf and dongle code, for that I am insisting on this.

推荐答案

我的解决方案是创建WPF项目,复制旧的.cs文件在该新项目中,并在其上添加对System.Windows.Forms的引用,以便仍然使用验证Windows窗体的旧功能。然后创建相同的方法,但将此时间传递给System.Windows.Controls.UserControl UC作为参数。
My solution has been to create WPF project, copy the old .cs files in that new project , and add on it a reference to System.Windows.Forms , in order to still using the old funcionality which validates Windows forms. Then create same methods but passing this time System.Windows.Controls.UserControl UC as a parameter.


这篇关于使用System.Windows.Controls作为参数而不是for的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆