Image within a RadioButton

I'm trying to insert an image next to the word in the RadioButton however am struggling as to how I'd do it?
23 Replies
Florian Voß
Florian Voß2y ago
@Midgeesaurus whats the issue? only the alignment?
Midgeesaurus
MidgeesaurusOP2y ago
Ish, If I drag it next to it, it just goes under or above.
Florian Voß
Florian Voß2y ago
I think it makes sense to have horizontal stackpanel around image and radiobutton. In case there are multiple of these you can also put a vertical stackpanel around those if that makes sense then they should be aligned due to the horizontal stackpanel I think
Midgeesaurus
MidgeesaurusOP2y ago
I may be a total beginner so that may have gone right around my head. sorry 🥲
Florian Voß
Florian Voß2y ago
oh wait I think StackPanel is horizontal by default so you do have it 🤔 mhmm
Midgeesaurus
MidgeesaurusOP2y ago
huh
Florian Voß
Florian Voß2y ago
the "Orientation" is what I'mt alking about
Midgeesaurus
MidgeesaurusOP2y ago
Yeah I'm still confused to be totally honest.
Florian Voß
Florian Voß2y ago
forget about it does the radio button change position if you apply verticalAlignment of center? cuz you have that set on the image but not on the radio button
Midgeesaurus
MidgeesaurusOP2y ago
No the image stays the same. It doesn't go into the box of the text
Florian Voß
Florian Voß2y ago
it seems you can only include image on radio button in wpf by customizing the radio button template. There are a lot of guides online for this
Midgeesaurus
MidgeesaurusOP2y ago
Okay I'll just have a look around. Cheers tho
MODiX
MODiX2y ago
That command had an error
UnknownCommand: Unknown command.
Remove your reaction to delete this message
Buddy
Buddy2y ago
$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
Buddy
Buddy2y ago
Avoid using the designer, because it uses Margin which is the spacing between items. Using Margin as the primary tool of doing layouts is bad, because it will lead to terrible bugs in the UI.
Midgeesaurus
MidgeesaurusOP2y ago
Thanks for the knowledge.
Buddy
Buddy2y ago
Always prefer doing layouts with the layout controls, such as Grid, StackPanel, DockPanel, etc.
Midgeesaurus
MidgeesaurusOP2y ago
Still all new too me, I've only been doing it a matter of 3 hours 🙂 I got bored of my xbox ofc and thought of a new hobby to try.
Buddy
Buddy2y ago
I highly suggest using Hot Reload. Just start your app (debug), and whenever you save the XAML the app will be redrawn live even when it's running!
Midgeesaurus
MidgeesaurusOP2y ago
currently doesnt give me the option too
Buddy
Buddy2y ago
If you use Visual Studio, go into options, then debugging and find Hot Reload. Make sure options there are enabled. If they are and it still isn't working. Use this link to troubleshoot it. https://learn.microsoft.com/en-us/troubleshoot/developer/visualstudio/tools-utilities/xaml-hot-reload-troubleshooting?view=vs-2022
Midgeesaurus
MidgeesaurusOP2y ago
tbh with the design ive gone for it looks better without the images.
Want results from more Discord servers?
Add your server