调整网格组件的大小UerControls [英] Resize Grid's components & UerControls

查看:69
本文介绍了调整网格组件的大小UerControls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF窗口,其宽度="800".高度="480".并在下面的代码内:

I have a WPF window with Width="800" Height="480" and inside ot the following code:

 


<Grid x:Name="LayoutRoot" Background="#E0000000" >

			<Grid x:Name="gridNoteBoard" ShowGridLines="True" >
				<Grid.RowDefinitions>
					<RowDefinition Height="*"/>
					<RowDefinition Height="*"/>
					<RowDefinition Height="*"/>
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
					<ColumnDefinition Width="*"/>
				</Grid.ColumnDefinitions>
			</Grid>
	</Grid>

推荐答案

当归,

有关您的问题,请参见下面的代码段.

Please see the code snippet below for ur issue.

Usercontrol XAML:

<UserControl x:Class="SandBox.UserControl7"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="Auto" Width="Auto" MinHeight="100" MinWidth="100">
    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <ListBox Background="Blue" Width="100" Grid.Column="0">
                <ListBoxItem>1</ListBoxItem>
                <ListBoxItem>2</ListBoxItem>
                <ListBoxItem>3</ListBoxItem>
                <ListBoxItem>4</ListBoxItem>
                <ListBoxItem>5</ListBoxItem>
                <ListBoxItem>6</ListBoxItem>
                
            </ListBox>
            <Button Content="MyButton" Height="25" Width="150" Grid.Column="1"></Button>
        </Grid>
    </ScrollViewer>
</UserControl>


Window XAML:

<Window x:Class="SandBox.Window25"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:SandBox"
    Title="Window25" Height="300" Width="300">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <local:UserControl7 Grid.Row="0" Grid.Column="0"></local:UserControl7>
    </Grid>
</Window>

在这种情况下,当您最小化窗口时,滚动条将可见,您可以在其中滚动并可视化您的控件.

Here in this case when u minimize the window the scrollbar will be visible where u can scroll through and visualise ur controls.

我希望这就是你想要的.

I hope this is what u want.

如果它解决了您的问题,请标记为答案.

Please mark it as an answer if it resolves ur issue.


这篇关于调整网格组件的大小UerControls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆