本文介绍了我可以添加的DependencyProperty的Windows用户控制的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想举办一个Visio ActiveX对象在WPF应用程序。

I'm trying to host a Visio ActiveX object in a WPF application.

要做到这一点,我创建了一个Windows用户控制项目中,我添加了Visio对象。该窗口的用户控件,然后驻留在一个的WindowsFormsHost对象的WPF用户控件上。

To do this, I created a Windows user control project where I add the Visio object. This windows user control is then hosted on an WPF user control in an WindowsFormsHost object.

<WindowsFormsHost Name="wfHost" Grid.Row="1">
    <wf:VisioUserControl FileNamePath="?"/>
</WindowsFormsHost>

我想这样做是对的 FileNamePath 的成员的值绑定到的值的文本框的元素,它定义的路径。

What I would like to do is to bind the value of the FileNamePath member to the value of a TextBox element which defines the path.

该项目遵循MVVM模式,所以没有我可以访问方式的 VisioUserControl 的对象,在我的视图模型。

The project follows the MVVM pattern, so there is no way that I can access the VisioUserControl object in my ViewModel.

我在想解决的办法是在 FileNamePath 的成员结合的的文本框的包含路径,但它不是一个的的DependencyProperty 的,似乎我无法在Windows用户的控制背后的code定义一个。

The solution I was thinking about is to bind the FileNamePath member to the value of the TextBox that contains the path, but it is not a DependencyProperty and it seems that I'm not able to define one in the code behind of the windows user control.

那么,有没有什么解决办法来执行这个绑定?

So, is there any workaround to perform this binding?

在此先感谢。

推荐答案

您可以通过创建解决这个问题的用户控件,它包装你的 VisioUserControl (我写了简单的用户控件创建此教程)。然后,您可以依赖属性添加 FileNamePath 用户控件。在属性改变了这种依赖属性的处理程序中,设置在 FileNamePath 属性 VisioUserControl 这个用户控件包装。

You can solve this by creating a UserControl that wraps your VisioUserControl (I wrote a simple tutorial on UserControl creation here). You can then add a FileNamePath dependency property to your UserControl. In the property changed handler of this dependency property, set the FileNamePath property on the VisioUserControl that this user control wraps.

这篇关于我可以添加的DependencyProperty的Windows用户控制的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 07:58