簡體   English   中英

在 WPF 中最大化 window 時如何調整內容大小?

[英]How to resize content when maximize window in WPF?

我有這個 window 並且我想調整內容的大小(適合 window 的大小)當用戶最大化這個 window 時,我嘗試了很多解決方案,但其中任何一個都對我有用:

<Window x:Class="Window_Image"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         d:DesignHeight="550" d:DesignWidth="550">
<Grid>
    <DockPanel LastChildFill="True" Name="ImgDock"  Background="Transparent" >
        <Image Source="../res/myimage.png" Width="450" Height="450" x:Name="ImageComp"  Visibility="Visible" > 
      </Image>
    </DockPanel>
</Grid>

我嘗試過的解決方案之一:

不幸的是,這個解決方案對我不起作用。

問題是Image大小是硬編碼的( HeightWidth屬性)。

默認情況下,大多數 WPF 組件將調整其大小以填充其容器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM