WPF UI appears different in debug
idk... My first WPF app. Looks like I matched the grid with the right coordinates. Still being weird.
What am I missing here?
14 Replies
Left image is the preview, right image is when I debug.
don't use the designer
it doesn't generate real layouts and just throws margins on things, which leads to problems like this
I am probably just doing something wrong in the xmlsn
in the xaml yes, using margins like this is a bad idea
you have a grid but you're not actually using it to lay out these controls
I honestly just placed the button and the textbox, everything else is just fatfingered
Yeah that grid just appears by my clicks
right, you should type the xaml yourself
the drag and drop editor is bad
$rulesofwpf
$wpfuilibs
MahApps
https://github.com/MahApps/MahApps.Metro
ModernWPF
https://github.com/Kinnara/ModernWpf
Adonis UI
https://github.com/benruehl/adonis-ui
Material Design
https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit
Biaui
https://github.com/YoshihiroIto/Biaui
HandyControl
https://github.com/HandyOrg/HandyControl
WPFUI (Windows 11 inspired)
https://github.com/lepoco/wpfui
Waves (WPF/Avalonia/More)
https://github.com/waves-framework/waves.ui.wpf
Use a grid with 2 columns and 2 rows. Both columns width *, * two rows one with height * the next auto
Place your box spanning across both columns in row 0, buttons in column 0 row 1 column 1 row 1
That'll center the buttons actually. You can use 1 column to keep the buttons side by side
I edited the xaml myself during runtime, but it still isn't fitting correctly at the top. As you can see in the screenshot.
For the grid:
I'm using 3 rows:
125+125+125
= 375 width
and 3 columns: 70+70+70
= 140 height
The window is the exact same 375 width, 140 height
but still as you can see at the top of the textbox, the text isnt fitting
Is this because of the bar at the top? Do I need to add that to the total?you're still explicitly sizing everything
layouts should be responsive to the window size
* 3 columns Auto,*,Auto
* 2 rows *,Auto
* text box at column 0 row 0 with a columnspan of 3
* start at column 0 row 1 with some margin/padding around it
* stop at column 2 row 1 with some margin/padding around it
alternative to some of the margin/padding is to set ratios for the grid sizes like
*,2*,*