C
C#2mo ago
Yarden

✅ How do I get to the graphical window (where I can drag and drop tools)

I'm studying some graphics now with WPF. I've added a button and label, but after I was running the program, the graphical window disappeared , how do I get it back? Thank you!
No description
61 Replies
ero
ero2mo ago
you don't have a solution open it says so on the right you should open the solution
Yarden
YardenOP2mo ago
Is it open now? I still don't see the graphics
No description
ero
ero2mo ago
it's not open, no
No description
ero
ero2mo ago
close visual studio and double click the sln file
Yarden
YardenOP2mo ago
I don't know where is the sln file, but I reopened visual studio Now I have this:
No description
ero
ero2mo ago
and now feel free to open one of the xaml files.
Yarden
YardenOP2mo ago
But it opens a code window and not the graphical window
Yarden
YardenOP2mo ago
it is like this:
No description
Yarden
YardenOP2mo ago
It's not drag and drop like it used to be
ero
ero2mo ago
first of all, you should not use the designer for wpf at all
Yarden
YardenOP2mo ago
why?
ero
ero2mo ago
$rulesofwpf
MODiX
MODiX2mo ago
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
Rules of WPF:

❌ Avoid the WPF Designer to eliminate a category of confusing bugs
❌ Don't rely on Margin as the primary tool for layouts
❌ Avoid writing UserControls or subclassing to extend a default control -- use Behaviors instead (Microsoft.Xaml.Behaviors.Wpf)

✅ Write XAML by hand and autoformat with "Ctrl K,D" or XAML Styler
✅ Rely upon XAML Hot Reload to design your app's UI at runtime
✅ Use layout controls (Grid, DockPanel, etc) to support proper resizing
✅ Use data binding to eliminate glue code and state synchronization issues
✅ Use collection controls and DataTemplate to dynamically create lists of controls
✅ Learn MVVM to create maintainable apps
✅ Use the Dispatcher to update controls from non-UI threads
✅ WPF's default controls can be easily modernized via $wpfuilibs
✅ Include relevant XAML, code-behind, and ViewModel code for questions when possible
ero
ero2mo ago
unless you really know what you're doing in wpf, dragging and dropping will lead to a app that looks wonky, can't be resized, etc there should be an option to enable the designer from the last window you showed
Yarden
YardenOP2mo ago
Yep I pressed right click on MainWindow.xaml and then designer So should I master wpf first and only then to use the design? in order to avoid bugs?
ero
ero2mo ago
i think you should use the designer first, find out that it can be annoying, and then slowly switch to only editing the xaml file directly that's what i did at least get familiar with the whole thing
Yarden
YardenOP2mo ago
Directly you mean by coding right?
ero
ero2mo ago
and then get better at it you know well, xaml isn't really "code"
Yarden
YardenOP2mo ago
For sure it seems like ten times more comfortable than javaFX For sure I'm starting to get confused 😂 But ok I'll follow what you said Thank you very much for the help🙏
ero
ero2mo ago
once you understand the xaml file, it kinda opens up a world for you you just add grids, grid rows and columns, and then add your individual controls on the grid, specifying their row and column, and their row/column span all stuff you'll learn over time i have the designer completely disabled in vs :p
leowest
leowest2mo ago
you dont use the designer at all for WPF other than for visually seeing if things look ok and even so you still should not trust it as it sometimes show things wrong but you should have an icon in the xaml window that lets u open the designer you write the XAML by hand
Yarden
YardenOP2mo ago
Ok I got you both
ero
ero2mo ago
the app can update most gui as it's running
leowest
leowest2mo ago
using the designer to drag and drop controls means u can render your UI out of screen its not like winforms
ero
ero2mo ago
it is like winforms though in winforms you also need a layout table which is their grid oh but you don't write the layout by hand :ah_err_bleh:
leowest
leowest2mo ago
you misunderstood me its not like winforms in the same you should use the drag and drop in the designer
ero
ero2mo ago
i mean you still shouldn't, really... you drag the control on there once, but then still change like 10 properties by hand...
leowest
leowest2mo ago
@Yarden you should have this
No description
leowest
leowest2mo ago
if u click design it will show it up
ero
ero2mo ago
winforms is just so inefficient
leowest
leowest2mo ago
unless u have it disabled in the settings
ero
ero2mo ago
yeah they got it
leowest
leowest2mo ago
u shouldn't drag and drop at all it adds attributes that are not intended so no they are not the same and if u want to split the screen with the designer
leowest
leowest2mo ago
No description
leowest
leowest2mo ago
it would be these on the right side
ero
ero2mo ago
no no i was just saying that you also shouldn't drag in winforms if it were possible
SpReeD
SpReeD2mo ago
Not if used correctly. In WPF you don't use the designer, because it's not like WinForms where the designer does work. The WPF-Designer is a mess, that's why it's not advised to use it, write XAML by hand, it saves many headaches. Note: It's an advice, use at own risk.
ero
ero2mo ago
since when you do drag, it's mostly just into a layout table, after which you still manually change things like row/column span, anchor, etc
Yarden
YardenOP2mo ago
Honestly I don't see this @er🎃 @SpReeD @leowest WinForms is another disgning technology of C#? It's totally newbie with this language
SpReeD
SpReeD2mo ago
WinForms, WPF, etc are GUI-Frameworks - they have nothing to do with the language C#
ero
ero2mo ago
i mean "nothing" might be a bit much...
leowest
leowest2mo ago
yes winform is a more noob friendly alternative if all u want to do is a mock something up with no cool look or anything just functional its windows only thou
ero
ero2mo ago
(so is wpf)
leowest
leowest2mo ago
nope
ero
ero2mo ago
it's literally the windows presentation foundation
leowest
leowest2mo ago
wpf learning curve for XAML is a barrier in comparison to getting started with winform on the other hand it have many good points winform does not which makes it a much better option for the long run, both in terms of modifying the look of the app and also in terms of modularity and scalability
ero
ero2mo ago
maui is the first party cross platform gui framework avalonia additionally works on linux but wpf is, like the name suggests, windows only
leowest
leowest2mo ago
@Yarden this is the run down very dumbed down for people that have no idea which c# ui framework to pick it doesnt include a few things but gives u a general idea https://raw.githubusercontent.com/Insire/diagrams/refs/heads/main/drawio-assets/.net-gui-overview.png
ero
ero2mo ago
this is out of date, avalonia can do mobile
leowest
leowest2mo ago
its not out of date its left out on purpose but you're free to share your opinion on #gui to insire
ero
ero2mo ago
ok it even says "platforms: andriod ios" so don't really get it
leowest
leowest2mo ago
anyway I dont want to turn this a discussion since its a help thread for Yarden so I rather keep it on topic for him reason why I pointed u to where to talk about the above image
ero
ero2mo ago
right
leowest
leowest2mo ago
anyway Yarden, about that image
No description
leowest
leowest2mo ago
you can find those on those corners
leowest
leowest2mo ago
if you closed it and only see the code or the designer it will look like this at the bottom
No description
leowest
leowest2mo ago
if u dont have it at all u might need to look into the settings to see if u disabled it Tools > Options > XAML Designer (at the very bottom)
leowest
leowest2mo ago
No description
Yarden
YardenOP2mo ago
Yep I found in the end Thank you all for helping me, your conversation helped me to understand few things, so it was blessed anyway. Thank you much!
leowest
leowest2mo ago
you're welcome 🙂 $close
MODiX
MODiX2mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server