question

Marcelsky-4530 avatar image
0 Votes"
Marcelsky-4530 asked DaisyTian-1203 commented

Button displaying weirdly on runtime

So essentialy the buttons i place just are in a different position at runtime

How its supposed to look like: 97577-zrzut-ekranu-2021-05-18-174822.png


How it looks like:
97550-zrzut-ekranu-2021-05-18-174906.png


windows-wpfdotnet-wpf-xaml
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Marcelsky-4530
This situation should be caused by setting the Margin of the Button. Control's position is affected by Margin, HorizontalAlignment, VerticalAlignment, <object margin="left,top,right,bottom" /> gets or sets the outer Margin of an element.


0 Votes 0 ·

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered Viorel-1 edited

Switch to XAML view and try the next example:

 <Window . . . Height="450" Width="800">
     <Grid>
         <Button Content="Button" HorizontalAlignment="Left" Margin="50,0,0,50" 
                       Width="150" Height="50" VerticalAlignment="Bottom"/>
     </Grid>
 </Window>

where “...” is something that is already added by system and you should not change.

Show your XAML too.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.