question

JerryM-2071 avatar image
0 Votes"
JerryM-2071 asked JerryM-2071 answered

How to insert UserControl into TabPage in .NET5 WPF ?

Hi,
I need to insert a UserControl onto a TabPage on a main form but it does not work for me.
I have .NET5 WPF project in MS VS 2019 v 16.9.4.
Can someone help me ? Here is my source code:

https://drive.google.com/file/d/1YACmuMXhZllATRnld901q6vDzK9iU0JE/view?usp=sharing

The command <app:ProcessView /> does not work and shows me this error:

Severity Code Description Project File Line Suppression State
Error XDG0008 The name "UserControl1" does not exist in the namespace "clr-namespace:WpfApp". WpfApp c:\1\WpfApp4 TabControl\WpfApp\WpfApp\MainWindow.xaml 12


thanks Jerry


windows-wpf
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Try rebuilding the solution using Build, Rebuild Solution menu command. Close and reopen the designers.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JerryM-2071 avatar image
0 Votes"
JerryM-2071 answered Viorel-1 commented

wooooou it is working ok... :) thanks

and by the way, do you know how to insert it dynamically based on "code behind" ???

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Try this:

 <TabItem x:Name="firstTab" Header="First">
 </TabItem>

In code:

 firstTab.Content = new UserControl1( );


0 Votes 0 ·
JerryM-2071 avatar image
0 Votes"
JerryM-2071 answered

thank you ... :)
j.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.