本文整理汇总了C#中System.Windows.Controls.ItemsControl.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# ItemsControl.UpdateLayout方法的具体用法?C# ItemsControl.UpdateLayout怎么用?C# ItemsControl.UpdateLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ItemsControl
的用法示例。
在下文中一共展示了ItemsControl.UpdateLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateIcon
protected void CreateIcon(Floor floor)
{
ItemsControl control = new ItemsControl();
Canvas canvas = new Canvas();
control.ItemTemplate = Application.Current.FindResource("SegmentRowTemplate") as DataTemplate;
canvas.Children.Add(control);
control.ItemsSource = floor.Segments;
control.UpdateLayout();
canvas.Measure(new Size(1000, 1000));
canvas.Arrange(new Rect(new Size(1000, 1000)));
RenderTargetBitmap bmp = new RenderTargetBitmap((int)control.DesiredSize.Width, (int)control.DesiredSize.Height, 96, 96, PixelFormats.Pbgra32);
bmp.Render(control);
floor.Icon = bmp;
}
示例2: BringItemIntoView
private TreeViewItem BringItemIntoView(ItemsControl container, object item)
{
TreeViewItem element = container.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
if (element != null)
element.BringIntoView();
else if (container.Items.Contains(item))
{
var vsp = (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember("_itemsHost", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, container, null);
if (vsp == null)
{
container.UpdateLayout();
vsp = (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember("_itemsHost", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, container, null);
}
if (vsp != null)
{
var index = container.Items.IndexOf(item);
if (index >= 0)
{
vsp.GetType().GetMethod("BringIndexIntoView", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(vsp, new object[] { index });
element = container.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
}
}
else
Debug.WriteLine("VirtualizingStackPanel NOT FOUND!!!");
}
return element;
}