本文整理汇总了C#中Visual.FindParentVisual方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.FindParentVisual方法的具体用法?C# Visual.FindParentVisual怎么用?C# Visual.FindParentVisual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.FindParentVisual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureAndWrapUsingScrollViewerIfNeeded
private static FrameworkElement ConfigureAndWrapUsingScrollViewerIfNeeded(Visual cell, object originalContent, FrameworkElement contentContainer)
{
var row = cell.FindParentVisual<DataGridRow>();
var dataGrid = row.FindParentVisual<DataGrid>();
var dockPanel = dataGrid.Parent as DockPanel;
if (dockPanel != null)
{
var headersPresenter = dataGrid.FindChildVisual<DataGridColumnHeadersPresenter>();
contentContainer =
new ScrollViewer
{
Content = contentContainer,
HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto
};
var scrollview = dataGrid.FindChildVisual<ScrollViewer>();
var binding = new MultiBinding { Converter = ChildContainerHeightConverter.Instance };
binding.Bindings.Add(new Binding(nameof(dockPanel.ActualHeight)) { Source = dockPanel });
binding.Bindings.Add(new Binding(nameof(headersPresenter.ActualHeight)) { Source = headersPresenter });
binding.Bindings.Add(new Binding(nameof(scrollview.ComputedHorizontalScrollBarVisibility)) { Source = scrollview });
contentContainer.SetBinding(FrameworkElement.MaxHeightProperty, binding);
var nestedContainer = (NestedContainer)(row.Tag ?? (row.Tag = new NestedContainer()));
nestedContainer.Items.Add(contentContainer);
}
row.Height = Double.NaN;
contentContainer.Tag = originalContent;
contentContainer.KeyDown += ContentContainerKeyDownHandler;
return contentContainer;
}