【问题标题】:How to set a value through binding for a Windows Forms UserControl in XAML?如何通过绑定在 XAML 中的 Windows 窗体 UserControl 设置值?
【发布时间】:2013-01-12 11:37:29
【问题描述】:

我正在处理这种情况。我有一个项目控件,其中作为项目模板我有一个 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>

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

【问题讨论】:

    标签: c# wpf xaml itemscontrol windowsformshost


    【解决方案1】:

    Databinding in WindowsForms and WPF Hybrid Apps

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-22
      • 2018-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多