如何停止在ItemControl中扩展到父级高度的WPF控件(使用扩展器)高度

如何停止在ItemControl中扩展到父级高度的WPF控件(使用扩展器)高度,第1张

概述如何停止在ItemControl中扩展到父级高度的WPF控件(使用扩展器)高度

我想在一个ItemControl中使用一个WrapPanel作为ItemsPanelTemplate,例如,我有一个UserControls hostest的视图

<GrID> <GrID.RowDeFinitions> <RowDeFinition Height="auto"></RowDeFinition> <RowDeFinition Height="*"></RowDeFinition> </GrID.RowDeFinitions> <StackPanel OrIEntation="Horizontal"> <TextBlock margin="5">No to load</TextBlock> <TextBox name="NumBox" WIDth="80" margin="5">1000</TextBox> <button WIDth="80" Height="25" Click="LoadClick">Load</button> <button Click="ClearClick" margin="5">Clear</button> </StackPanel> <ScrollVIEwer GrID.Row="1" margin="3" VerticalScrollbarVisibility="auto" > <ItemsControl ItemsSource="{Binding Data}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel OrIEntation="Horizontal" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <local:TestControl2></local:TestControl2> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollVIEwer> </GrID>

TestControl2的定义如下

<UserControl x:Class="WpfWrapPanelTest.TestControl2" 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" Height="auto" WIDth="120" margin="10"> <border Background="Bisque" CornerRadius="10" Height="auto"> <StackPanel> <Expander header="Options 1" ExpandDirection="Down"> <StackPanel> <TextBlock>Item1</TextBlock> <TextBlock>Item2</TextBlock> </StackPanel> </Expander> <Expander header="Options 2" ExpandDirection="Down"> <StackPanel> <TextBlock>Item1</TextBlock> <TextBlock>Item2</TextBlock> <TextBlock>Item3</TextBlock> <TextBlock>Item4</TextBlock> </StackPanel> </Expander> </StackPanel> </border> </UserControl>

这里的问题是,当我扩展扩展器之一…以及控制扩展高度(我想要的),同一行中的所有其他控件的高度也增长。

有没有办法阻止同一行中的所有其他控件的高度增长?

为什么我的程序不能从Program files目录运行,而是从其他地方运行?

为什么我的.NET windows服务有时不会自动启动?

如何获得当前windows用户的*networking身份,而不是他们的交互式login身份?

Visual Studio图标的含义

windows 8 Embedded中缺lessMSVCR120_CLR0400.dll

在此先感谢您的帮助。

.NET中的vista / win7放大API

如何确定WPF .NET应用程序是否已经进入windows 10平板电脑模式?

与windows服务运行UI

file.copy()到同一台机器上的networking共享是否通过networking复制文件?

为什么在通过Shell32读取公共快捷方式时遇到E_ACCESSDENIED?

这里的问题是, FrameworkElement的VerticalAlignment属性默认为Stretch 。 你需要通过指定一些其他的垂直对齐来在树中的某个点上打破这个。 我的建议是将您的DataTemplate更改为:

<local:TestControl2 VerticalAlignment="top"></local:TestControl2>

总结

以上是内存溢出为你收集整理的如何停止在ItemControl中扩展到父级高度的WPF控件(使用扩展器)高度全部内容,希望文章能够帮你解决如何停止在ItemControl中扩展到父级高度的WPF控件(使用扩展器)高度所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1278889.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存