C
C#2y ago
Xato

❔ XAML Designer WPF

im new to c# and programming. im using visual studio to make wpf program where you guess a number. im using chatgpt to tell me how to do this. it says double click the MainWindow.xaml to open the XAML designer. i did that but i dont think it opened? because theres no toolbox where i can select text box, button, label etc. and those are what i want to create. what do i do?
11 Replies
Angius
Angius2y ago
im using chatgpt to tell me how to do this
Your first mistake Also, don't use the designer Just edit the XAML file and type in your controls $rulesofwpf
MODiX
MODiX2y 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
Xato
XatoOP2y ago
right okay so i have to learn to do that i guess
Auger
Auger2y ago
Why do we avoid subclassing default controls?
Angius
Angius2y ago
¯\_(ツ)_/¯ Wasn't me who made this tag
MODiX
MODiX2y ago
The Associate role
Owns the 'rulesofwpf' tag.
Use tags inline with "$name"
Angius
Angius2y ago
¯\_(ツ)_/¯
Auger
Auger2y ago
Lol
Klarth
Klarth2y ago
Ask @Insire . But mostly because behaviors are better: composable, doesn't require styling changes, etc.
Insire
Insire2y ago
because no styling library will work with subclassesed controls out of the box also, subclassed controls do not support sharing their functionality, behaviors and attached properties are the way to go for that
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server