⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemscontroluiadapterfactory.cs

📁 wpf和cab的结合使用源码(转载)
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Microsoft.Practices.CompositeUI.UIElements;

namespace Microsoft.Practices.CompositeUI.Windows.UIElements
{
	/// <summary>
	/// Implements <see cref="IUIElementAdapterFactory"/> for WPF applications.
	/// </summary>
	public class ItemsControlUIAdapterFactory : IUIElementAdapterFactory
	{
		public IUIElementAdapter GetAdapter(object uiElement)
		{
			//dunno if this is right yet
			Debug.Assert(uiElement is FrameworkElement);
			ItemsControl itemsControl = GetAncestorItemsControl(uiElement as FrameworkElement);
			Debug.Assert(itemsControl != null);
			return new ItemsControlUIAdapter(itemsControl);
		}

		public bool Supports(object uiElement)
		{
			return (GetAncestorItemsControl(uiElement as FrameworkElement) != null);
		}

		private ItemsControl GetAncestorItemsControl(FrameworkElement frameworkElement)
		{
			while ((frameworkElement != null) && (!(frameworkElement is ItemsControl)))
			{
				frameworkElement = frameworkElement.Parent as FrameworkElement;
			}

			return frameworkElement as ItemsControl;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -