✅ Alignment messed up?
The screenshots should explain it. Any idea on how to fix this?
82 Replies
So yea.. the alignment gets messed with
This is the xaml for the right screenshot..
wpf designer is not accurate
its also in the app
i recommend not using it
huh..?
How should I design then
use xaml hot reload
while the app is running
oh so it just refreshes while the app is running?
yeah
and you see how the actual app will look like
because it is the actual app
but I think I found it:
The Borders are a fixed size.. Can I make them dynamic so they take on spot in the StackPanel?
or rather.. one half
i dont understand your issue
yes, it is like that in the actual app
its not aligned correctly when inserting the usercontrol
Discover is Centered, but the Borders aren't
I assume because it "shrinks", while keeping the borders at a fixed size
yeah your borders have a fixed size
yes
how can I solve that?
dont set a fixed size
Yea.. but what should I do instead
is there a way to get the total width and devide by 2?
e.g.
4*
what's that?
you can set the ratios with stars
its easier to explain with grid columns
so say we have this
this syntax isnt supported in wpf xaml but it just means 2 columns, with the width set to
*
for each of them
this means that both columns are the same size, so the are is divided equally between them
its equivalent to ColumnDefinitions="1*,1*"
now if we change that to ColumnDefinitions="2*,1*"
that makes the width ratio between them 2:1Okay
which means the first column will take 2/3 of the space
and the second one will take 1/3
you can do the same thing with the items in the stackpanel
so essetially the
*
makes the sizes relative
you get what i mean?
so
these widths are now relative
but a ratio of 400:400 is the same as 1:1
so each will take half
so thats the same as
Yes, trying to implement it xD
i recommend keeping all sizes relative in your usercontrol
but the star doesnt work
why
what do you get
Wait lemme send u the edited part
a stackpanel wouldve also worked :)
oh.. xD
Lemme change it back rq
you need to make all your widths relative
what you have now, makes the first border take all the sapce thats left after the second border takes 400
Invalid property value for Width '1*'
ah
oh right
grid
so we need a grid? xD
you need to set the widths of the grid columns
ahhh im confused
instead of borders themselves
Still
oh
ahhh
uhm
Border clip is making a bit of troublke now
what
<Border.Clip>
for the rounded corners
screenshot
discord is not having it again
in the actual app
ah youre setting the size for that explicitly as well
just set CornerRadius
it doesnt have it
how
Nevermind
lmao
I thought I tried that already
but if youre going to keep all the sizes of the border equal
just use a stackpanel
stackpanel inside the grid?
no instead of the grid
can u still use the ratio size?
oh
ohhh
it divides equally by default
uhm
show the whole usercontrol
first try adding
HorizontalAllignment="Stretch"
to the stackpanelit's the whole
i meant the code
the entire usercontrol :)
sorry
no worries
its vertical
dont work
Wait
nvm, where is it vertical?
huh
why doesnt this work
wtf
idk
orientation of the stackpanel
<StackPanel Height="200" Orientation="Horizontal" HorizontalAlignment="Stretch">
Still, nothing :(
yeah the borders are taking the minimum width
which is 0
for some reason
hmm..
So is there another thing we can try?
Maybe like getting the current size of the ctrl then deviding by 2?
im trying to think of a clean solution
will the number of controls in the stack panel change?
ah
im an idiot
just use a uniform grid
lmao
@Mettwasser
whats that
Seems to work
looks like a cleaner, simplified version of Grid
it divides space equally between the controls
and by limiting the rows to 1
its essentially a stackpanel
but instead lf columns of size
auto
its columns of size *
basicallyok gotchu
tyvm
np
how do I close this?
$close
Use the /close command to mark a forum thread as answered
!close
Closed!