简体   繁体   中英

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

I'm dealing with this situation. I've got an items control where as item template I've got a windows forms userControl, and in code behind I'm setting the ItemsSource, but I don't know to set some data in the userControl.

In it UserControl I have some datagridview with specific structure, and WPF grid view is not useful for me. So I can't change this usercontrol.

       <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>

What can I do to access that usercontrol and set some values?

Databinding in WindowsForms and WPF Hybrid Apps

Because Windows Forms is involved, XAML databinding will not work entirely. You need to set up data binding in the code behind.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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