❔ WPF Toolbox in visual does not autofill
Hello friends, I have a problem in Visual Studio 2022, when creating a WPF or WPF (Net Framework) template, when I enter the solution and use the toolbox to add components to the window I get that there are no usable controls In this group, I can add them from [Choose Toolbox Elements] from the Tools menu but when I leave the project and reopen it, the components I select are removed (Note: I was going to take a photo of the menu where I select the WPF elements but I got this thing that you see in the photo), as you can see I have the option for Visual to autofill the toolbox active but even if activated or deactivated nothing happens and I reinstalled the .NET desktop development package, I'm learning to start in my C# course and I reached the Graphical Interface part but now with this problem I cannot advance since the course does not work on this part with code from scratch.
I would really appreciate your help and thank you in advance.
44 Replies
You should not use the toolbox for WPF
The designer is terrible and causes layout issues.
Please use the XAML to design your app
as well as take use of hot reload
How is it used? I'm doing a course on YouTube and that's what the programmer uses (I emphasize that his video is from 2019)
XAML is similar to how web developers use HTML, except it's an all-in-one kind of language.
Both styling, design / layout, and code binding is written in XAML.
you write the xaml while your app is running
and see the changes on the actual app
Your suggestions are advanced for my information about visual and this for now, here I leave the video that I was watching about WPF and if you want you can fast forward it and see something (It is in Spanish but the detail is that you see what he does)
1. Do not use designer
2. Use XAML
3. Do not use the designer
you can still follow the video
just whenever they use the designer you write it out yourself
Do you suggest that I learn the WPF syntax?
pildorasinformaticas
YouTube
Curso C#. WPF Interfaces gráficas I. Vídeo 72
Comenzamos con este vídeo a ver las interfaces gráficas con C#. Utilizamos la API de .NET: el "WPF", sustituto de Windows Forms para crear interfaces.
Para más cursos, ejercicios y manuales visita: www.pildorasinformaticas.es
Yes
This is one of the reasons I hate YouTube courses, they only teach people bad habits. No actual useful information is given.
Is it in the NET API?
Take use of intellisense, but they have docs of each control. Not really any "tutorial" for it.
It's easy to learn XAML, just the advanced parts are bindings and styling.
Where can I download that pdf in Spanish for free?
You seem to know English already?
scroll down bud
I literally have the translator open in another window
Thank you very much for your help
pretty good translator
I've used the designer for years and have never encountered any kind of issue except for the VS2022 designer having a 1 pixel offset on everything
what kind of issues have you gotten?
$rulesofwpf
- ❌ Avoid the WPF Designer to eliminate a category of confusing bugs
- ❌ Don't rely on Margin as the primary tool for layouts
Designer uses Margin as the primary tool of doing layouts
Margin is the spacing between elements, it isn't absolute position
I can kinda get that part for making apps on different DPI monitors, but apart from that I don't see anything wrong with it
Try resizing your application
and see how it goes
😉
In the designer?
No?
Oh while it's running... well they resize just fine
I don't blindly only use margins though, I use stack panels, dock panels, grid rows/columns, etc.
Margins are just handy sometimes
Exactly.
Let me see your XAML
Mainly when I can't figure out how else to do something
Designer uses Margin
Which is the reason why you should never use Designer as well as it isn't the actual preview
Please use hot reload, don't use designer
Yeah but you can use the gizmos to do non-margin based layouts
like clicking the things that toggle vertical/horizontal alignment
I can#'t really find anything specific to share as an example
I currently only use margins to make the borders between controls work
I use 1 pixel borders between panels instead of large gaps
Wait i found something
Yeah, please don't recommend using designer. Even if you personally have no issues with it.
It shouldn't be a designer but a "preview".
You don't use the designer
meaning drag n drop
I mean I do but if you say so...
I use the designer to get an initial layout, then do some XAML work to get finer details
not sure what you call this thing but it toggles the horizontal alignment of the selected control, and then you can just drag it to the edge of the parent and the designer automatically removes the margin at that point
then there's also the left and top bars when you select a component inside a Grid which lets you create a row/column at the mouse cursor which is convenient instead of writing like 5 lines of XAML
You use the designer as a preview it seems, not as you would in windows forms
that's the point. Designer uses Margins.
For the most part yeah
in my experience its been much worse than 1 px offset
and the offsets are not consistent
sometimes it renders something completely wrong
also the xaml it generates is garbage
also if youre only using it as a preview why not just use hot reload
I guess i've just been lucky then... never had problems with it until VS2022 with that 1 pixel offset like in this image; that blue selection outline shouldn't overlap the checkbox's rectangle
I use hot reload though when I wanna play around with the style of actual live data which the designer can't really do, but the designer is still handy for getting an initial UI layout, and then I can go into the XAML and fix it up if nesessary
i wouldn't enjoy using WPF as much if there was no designer because of things like the Grid gizmos I mentioned where clicking anywhere on those lines generates about 30 seconds of code instantly
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.