C
C#β€’3y ago
NeoπŸ‘‘

❔ 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
Angiusβ€’3y 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
MODiXβ€’3y 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
NeoπŸ‘‘
NeoπŸ‘‘OPβ€’3y ago
right okay so i have to learn to do that i guess
Auger
Augerβ€’3y ago
Why do we avoid subclassing default controls?
Angius
Angiusβ€’3y ago
Β―\_(ツ)_/Β― Wasn't me who made this tag
MODiX
MODiXβ€’3y ago
The Associate role
Owns the 'rulesofwpf' tag.
Use tags inline with "$name"
Angius
Angiusβ€’3y ago
Β―\_(ツ)_/Β―
Auger
Augerβ€’3y ago
Lol
Klarth
Klarthβ€’3y ago
Ask @Insire . But mostly because behaviors are better: composable, doesn't require styling changes, etc.
Insire
Insireβ€’3y 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
Accordβ€’3y 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.

Did you find this page helpful?