C
C#6mo ago
Vegas

VS 2022 - Root Element is not valid - WPF

So upon trying to get a TextBlock to read across all pages, i somehow ended up with this error. And cand figure out where its coming from.
No description
No description
8 Replies
Vegas
VegasOP6mo ago
No description
Buddy
Buddy6mo ago
Mind sending the XAML? $paste
MODiX
MODiX6mo ago
If your code is too long, you can post to https://paste.mod.gg/, save, and copy the link into chat for others to see your shared code!
Vegas
VegasOP6mo ago




Buddy
Buddy6mo ago
So upon trying to get a TextBlock to read across all pages,
Use MVVM and Dependency Injection, it's more advanced but it's just what you need. Oh my. Remember this. $rulesofwpf
MODiX
MODiX6mo 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
Buddy
Buddy6mo ago
Specifically this
❌ Avoid the WPF Designer to eliminate a category of confusing bugs
Vegas
VegasOP6mo ago
Source="MainWindow.xaml" This was it, I forgot to remove this part from the guide i followed thta didnt work.
Want results from more Discord servers?
Add your server