当我调整窗口大小时,按钮不会随之调整大小,其他所有类似网站的内容都会显示,但按钮不会。我尝试使用“边框”方法,但只能固定调整内容的大小,背景也可以正常工作。
<Window Title="MainWindow" Height="700" Width="980"
Background="Transparent" >
<Border>
<Grid MinHeight="1" MinWidth="1">
<Grid.Background>
<ImageBrush Stretch="UniformToFill" ImageSource="images\tarkov wallpaper.jpg"/>
</Grid.Background>
<Button x:Name="fleam" Click="flea_click" Background="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="245" Height="51" Margin="734,52,0,0" BorderThickness="0" >
<Image Source="images\flea.png" Height="51" Width="235" Stretch="Fill" />
</Button>
<Button x:Name="maps" Click="map_click" Background="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="245" Height="51" Margin="491,52,0,0" BorderThickness="0" >
<Image Source="images\maps.png" Height="51" Width="245" Stretch="Fill" />
</Button>
<Button x:Name="ammo" Click="ammo_click" Background="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="245" Height="51" Margin="246,52,0,0" BorderThickness="0" >
<Image Source="images\ammo.png" Height="51" Width="245" Stretch="Fill" />
</Button>
<Button x:Name="armor" Click="armor_click" Background="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Width="245" Height="51" Margin="1,52,0,0" BorderThickness="0" >
<Image Source="images\armor.png" Height="51" Width="245" Stretch="Fill" />
</Button>
<eo:WebControl x:Name="fleamarket" Margin="10,108,10,0" Visibility="Hidden">
<eo:WebControl.WebView>
<eo:WebView Url="https://tarkov-market.com/">
</eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>
<eo:WebControl x:Name="map" Margin="10,122,-5,10" Visibility="Hidden">
<eo:WebControl.WebView>
<eo:WebView Url="https://mapgenie.io/tarkov">
</eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>
<eo:WebControl x:Name="ammon" Margin="10,108,10,10" Visibility="Hidden">
<eo:WebControl.WebView>
<eo:WebView Url="https://docs.google.com/spreadsheets/d/1_l-gYeSt2MqIw62EdMZt_wefG0yO9L7dTaRM74c2J1w/edit#gid=2023683591" >
</eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>
<Image x:Name="armorimg" Source="images/amorcont.jpg" Margin="-18,108,-18,0" Visibility="Hidden"/>
</Grid>
</Border>
</Window>
答案 0 :(得分:0)
首先,尝试为Grid
定义行和列。
其次,删除控件的Width
和Height
属性。
最后,使用Margin
属性确定Grid
单元内控件的相对大小和位置。
该代码将帮助您:
<Window Title="MainWindow" Height="120" Width="120">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Margin="10">Button 1</Button>
<Button Grid.Column="1" Margin="10">Button 2</Button>
<Button Grid.Column="2" Margin="10">Button 3</Button>
<Button Grid.Row="1" Margin="10">Button 4</Button>
<Button Grid.Column="1" Grid.Row="1" Margin="10">Button 5</Button>
<Button Grid.Column="2" Grid.Row="1" Margin="10">Button 6</Button>
<Button Grid.Row="2" Margin="10">Button 7</Button>
<Button Grid.Column="1" Grid.Row="2" Margin="10">Button 8</Button>
<Button Grid.Column="2" Grid.Row="2" Margin="10"Button 9</Button>
</Grid>
</Window>