Loading WPF User Control at runtime

Need to place the user control in a control that accepts content. My current favourite is a “ContentControl”.

Me.ContentCanvas.Content = userControlValue
Me.ContentCanvas.Content = Nothing

Some other controls require Add.

Beware that a StackPanel will expand to fit all content, so if you put a DataGrid and possibly a ListBox in there, there will be no scroll bar.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: