繁体   English   中英

如何通过绑定为XAML中的Windows窗体用户控件设置值?

[英]How to set a value through binding for a Windows Forms UserControl in XAML?

我正在处理这种情况。 我有一个项目控件,在这里我有一个Windows窗体userControl作为项目模板,在后面的代码中我设置了ItemsSource,但是我不知道在userControl中设置一些数据。

在其中的UserControl中,我有一些具有特定结构的datagridview,而WPF网格视图对我没有用。 因此,我无法更改此用户控件。

       <ItemsControl x:Name="itemsControl">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <WindowsFormsHost x:Name="wfh" Grid.Column="2" Margin="10,0,0,10" />
                        <local:StudentHistoryUserControl />
                    </WindowsFormsHost>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>

如何访问该用户控件并设置一些值?

WindowsForms和WPF混合应用程序中的数据绑定

由于涉及Windows窗体,因此XAML数据绑定将无法完全起作用。 您需要在后面的代码中设置数据绑定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM