开发者

How to restore controls in their correct places same as earlier when we maximize a window?

开发者 https://www.devze.com 2023-03-09 09:28 出处:网络
I am creating a wpf application.It contains a ListBox in which there are 3 buttons that are to be put on extreme right hand side one after another .The problem is that when I maximize that window ,the

I am creating a wpf application.It contains a ListBox in which there are 3 buttons that are to be put on extreme right hand side one after another .The problem is that when I maximize that window ,the buttons does not take their correct places as used to be in earlier window i.e. They should be on the extreme right hand side of the form one after another.But now they are shown in the middle of the ListBox..Please guys help me to solve开发者_StackOverflow社区 this problem ASAP..


With no code to go on, I can only assume you're using absolute positioning. That would explain why it only works when your Window is a certain size. If you instead use relative positioning, you can achieve your goals.

There are many ways to do this, and you should read up on WPF layout if you're unfamiliar with it. Here is one example:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    <ListBox/>
    <StackPanel Grid.Column="1">
        <Button>One</Button>
        <Button>Two</Button>
        <Button>Three</Button>
    </StackPanel>
</Grid>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号