当前位置: 首页 > 编程语言 > C#

自动高度与MaxHeight结合使用分享

时间:2023-04-11 01:40:39 C#

C#学习教程:使用MaxHeight自动高度当我将height="auto"替换为height="*"时,一切正常,而水平和垂直滚动条看起来符合预期。当我直接在DataGrid1上声明MaxHeight时它也有效,但这不是我想要的。这是一个bug,是childcontrol在设置Height="Auto"时忽略了最大高度,还是我做错了什么?可以使用ListBox/ListView等重现相同的行为,也可以使用ComponentOne、Telerik等第3方控件重现...如果这是一个错误-您是否知道解决方法或有其他提示?下面是我如何设置DataGrid的ItemsSource的代码。RowHeightAuto.xaml.cspublicpartialclassRowHeightAuto:Window{privatereadonlyDateTime_start;publicRowHeightAuto(){InitializeComponent();DataGrid1.ItemsSource=GetTestData();_start=DateTime.Now;Dispatcher.BeginInvoke(newAction(()=>MessageBox.Show((DateTime.Now-_start).TotalSeconds.ToString(CultureInfo.InvariantCulture))),DispatcherPriority.ContextIdle,null);}publicstaticListGetTestData(){constintmaxCols=501;constintmaxRows=300;vartestDatas=newList(maxRows);对于(inti=0;i