XAML UI Preview on Visual Studio
Hi, I am a beginner in C# trying to read through some popular github repos to learn a bit.
I can't figure out how to preview the UI of some XAML files on Visual Studio Community.
What I saw online are options that don't appear for me when right clicking the file like "Display in Designer" or options to display after running the program.
I know from work that a split display of code and UI is possible in design time but I couldn't figure out the setting to do so on the toolbar or from the menus.
Help would be appreciated ❤️
9 Replies
have you opened the solution properly, and not just the folder its in?
that said, the recommendation for xaml is usually to not bother with the designer
$rulesofwpf
Not all files with '.xaml' ext can display. Some files may be resource dictionaries, only UserControl or Window can display in designer.
Yes, I opened the .sln file in the root of the project which is PowerToys.sln
https://github.com/microsoft/PowerToys/tree/main
GitHub
GitHub - microsoft/PowerToys: Windows system utilities to maximize ...
Windows system utilities to maximize productivity. Contribute to microsoft/PowerToys development by creating an account on GitHub.
So a C# developer doesn't usually verify the UI in designtime, but rather opt to run the program and use things like XAML Hot Reload to touch up on the UI in runtime?
yup
oh interesting. I was trying to open MainWindow.xaml and Pages/MainPage.xaml in the link below which its code looked to have some UI elements like Grid, Image, Rectangle.
Can these files display in your opinion?
https://github.com/microsoft/PowerToys/tree/main/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML
GitHub
PowerToys/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML...
Windows system utilities to maximize productivity. Contribute to microsoft/PowerToys development by creating an account on GitHub.
Okay thanks I will look into the errors I get and see how I can fix them.
I just thought I am missing some secret C# package that will allow me to preview the pages I have in design time
XAML can pull from many sources, including from objects created by C# at runtime. So it is hard to keep a designer/previewer happy and usable even if one exists for your GUI framework.
Running the app + using XAML Hot Reload is a much better dev experience than previewers...which are only as good as the data you feed it.