本文整理汇总了C#中System.Windows.Controls.ContentPresenter.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# ContentPresenter.ApplyTemplate方法的具体用法?C# ContentPresenter.ApplyTemplate怎么用?C# ContentPresenter.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ContentPresenter
的用法示例。
在下文中一共展示了ContentPresenter.ApplyTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _captureSnapshot
// captures a snapshot of the given presenter to a cached bitmap
private Image _captureSnapshot(ContentPresenter presenter, bool hidePresenter) {
if (hidePresenter) presenter.Visibility = Visibility.Hidden;
var content = presenter.Content as FrameworkElement;
if (content == null) return null;
// force full layout and capture snapshot
presenter.ApplyTemplate();
presenter.UpdateLayout();
return new Image {
Source = ImageServices.CaptureSnapshot(content)
};
}
示例2: CreateChildContentPresenter
internal ContentPresenter CreateChildContentPresenter(object item)
{
if (item == null)
return null;
ContentPresenter cp = FindChildContentPresenter(item);
if (cp != null)
return cp;
// the actual child to be added. cp.Tag is a reference to the TabItem
cp = new ContentPresenter();
cp.Content = (item is TabItem) ? (item as TabItem).Content : item;
cp.ContentTemplate = this.SelectedContentTemplate;
cp.ContentTemplateSelector = this.SelectedContentTemplateSelector;
cp.ContentStringFormat = this.SelectedContentStringFormat;
cp.Visibility = System.Windows.Visibility.Collapsed;
cp.Tag = (item is TabItem) ? item : (this.ItemContainerGenerator.ContainerFromItem(item));
ItemsHolderPanel.Children.Add(cp);
cp.ApplyTemplate();
return cp;
}