代码之家  ›  专栏  ›  技术社区  ›  Eric Obermuller

将窗口的最小高度和最小宽度绑定到页面

  •  0
  • Eric Obermuller  · 技术社区  · 6 年前

    这就是设置。我的窗户里有一个框架,里面装着我所有的书页。当我浏览网页时,我希望能够绑定 窗的 最小宽度和最小高度基于 我在。所以基本上我希望窗口的最小宽度和最小高度是基于每个页面的最小宽度和最小高度。

    这是我的相框

    <Window x:Class="Project_Tracking.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ignore="http://www.galasoft.ch/ignore"
        mc:Ignorable="d ignore"
        Title="Project Tracking"
        Icon="/Images/AlarmClock.ico"
        WindowStartupLocation="CenterScreen"
        DataContext="{Binding Main, Source={StaticResource Locator}}">
    
    <Grid>
        <Frame x:Name="mainFrame" Source="/Views/LoginView.xaml" NavigationUIVisibility="Hidden">
    
        </Frame>
    </Grid>
    

    我在这个应用程序中使用mvvm light。我正在寻找一个建议,不使用背后的代码。非常感谢您的帮助!

    1 回复  |  直到 6 年前
        1
  •  0
  •   computoms    6 年前

    尝试绑定 MinWidth MinHeight 框架内容的属性:

    <Window x:Class="TestProject.MainWindow"
        MinWidth="{Binding Content.MinWidth, ElementName=mainFrame}"
        MinHeight="{Binding Content.MinHeight, ElementName=mainFrame}"
        Title="MainWindow">
    <Grid>
        <Frame x:Name="mainFrame" Source="Views/LoginView.xaml">
    
        </Frame>
    </Grid>
    

    我的例子似乎只有一页。