小编Xex*_*las的帖子

如何将 WPF 窗口嵌入到另一个窗口中并通过 XAML 或代码调整其大小

首先,这是我使用 Xaml 的第一天,所以这个问题对你来说可能是虚拟的,但我完全迷路了。

概述

我的技术是我有 MainWindow.xaml ,它分为三个区域(使用网格列),列宽度自动设置。

根据右列中的一些操作,中间列显示一个页面,假设 Page.xaml 存在于不同的命名空间中。

我在寻找什么

问题是我需要将此页面的宽度和高度设置为等于中间列的宽度和高度,因为它将适合该区域。

笔记

我对 xaml 和绑定技术的经验很少。

主窗口.Xaml

<Window 
    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" mc:Ignorable="d" 
    WindowState="Maximized"
    ResizeMode="NoResize"
    WindowStartupLocation="CenterScreen"
    Title="MainWindow" d:DesignWidth="1366" d:DesignHeight="768">

<Grid x:Name="MainGrid">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1.2*" x:Name="LeftColoumn" />
        <ColumnDefinition Width="3*" x:Name="CenterColoumn" />
        <ColumnDefinition Width=".8*" x:Name="RightColoumn" />
    </Grid.ColumnDefinitions>

    <ScrollViewer Grid.Column="2">
        <StackPanel Orientation="Vertical" x:Name="RightStackPanel" Background="LightGray" >
            <Border BorderBrush="{x:Null}" Height="50" >
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" FontWeight="SemiBold" FontStyle="Normal" Margin="3" FontSize="20" >Others</TextBlock>
            </Border>
            <Expander x:Name="Expander1" Header="Others" Margin="0,0,10,0">
                <Button  Margin="0,0,0,0"  Width="{Binding ActualWidth, ElementName=RightStackPanel}" Background="White" Content="Add" Height="50" Click="Button_Click" ></Button> …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml user-controls wpf-controls

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

user-controls ×1

wpf ×1

wpf-controls ×1

xaml ×1