当前位置: 首页>>代码示例>>C#>>正文


C# TabItem.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.TabItem.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TabItem.SetValue方法的具体用法?C# TabItem.SetValue怎么用?C# TabItem.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.TabItem的用法示例。


在下文中一共展示了TabItem.SetValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrepareContainerForItem

        /// <summary>
        /// Override to change how TabItem's are prepared for items.
        /// </summary>
        /// <param name="item">The item to wrap in a TabItem</param>
        /// <param name="parent">The parent <see cref="DependencyObject"/></param>
        /// <returns>A tab item that wraps the supplied <paramref name="item"/></returns>
        protected virtual TabItem PrepareContainerForItem(object item, DependencyObject parent)
        {
            TabItem container = item as TabItem;
            if (container == null)
            {
                object dataContext = GetDataContext(item);
                container = new TabItem();
                container.Content = item;
                container.Style = TabControlRegionAdapter.GetItemContainerStyle(parent);
                container.DataContext = dataContext; // To run with SL 2
                container.Header = dataContext; // To run with SL 3                  
                container.SetValue(IsGeneratedProperty, true);
            }

            return container;
        }
开发者ID:ssethi,项目名称:TestFrameworks,代码行数:22,代码来源:TabControlRegionSyncBehavior.cs

示例2: GetName_AttachedProperty1Event

		public override void GetName_AttachedProperty1Event ()
		{
			if (!EventsManager.Instance.AutomationSingletonExists) {
				EnqueueTestComplete ();
				return;
			}

			TabControl tabControl = new TabControl ();
			TabItem tabItem = new TabItem ();
			CreateAsyncTest (tabControl,
			() => {
				AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (tabItem);
				AutomationPropertyEventTuple tuple = null;

				TextBlock textblock = new TextBlock () { Text = "Hello world:" };
				AutomationPeer textblockPeer = FrameworkElementAutomationPeer.CreatePeerForElement (textblock);

				EventsManager.Instance.Reset ();
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#0");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.NameProperty, "My name");
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#1");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.LabeledByProperty, textblock);
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNotNull (tuple, "#2");

				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.LabeledByProperty);
				Assert.IsNotNull (tuple, "#3");

				EventsManager.Instance.Reset ();
				textblock.Text = null;
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNotNull (tuple, "#4");

				tuple = EventsManager.Instance.GetAutomationEventFrom (textblockPeer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNotNull (tuple, "#5");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.LabeledByProperty, null);
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#6");

				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.LabeledByProperty);
				Assert.IsNotNull (tuple, "#7");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:51,代码来源:TabItemAutomationPeerTest.cs

示例3: GetName_AttachedProperty0Event

		public override void GetName_AttachedProperty0Event ()
		{
			if (!EventsManager.Instance.AutomationSingletonExists) {
				EnqueueTestComplete ();
				return;
			}

			TabControl tabControl = new TabControl ();
			TabItem tabItem = new TabItem ();
			CreateAsyncTest (tabControl,
			() => {
				AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (tabItem);
				AutomationPropertyEventTuple tuple = null;

				EventsManager.Instance.Reset ();
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#0");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.NameProperty, "Attached Name");
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#1");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.NameProperty, "Name");
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#4");

				EventsManager.Instance.Reset ();
				tabItem.SetValue (AutomationProperties.NameProperty, null);
				tuple = EventsManager.Instance.GetAutomationEventFrom (peer, AutomationElementIdentifiers.NameProperty);
				Assert.IsNull (tuple, "#7");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:34,代码来源:TabItemAutomationPeerTest.cs

示例4: GetName_AttachedProperty1

		public override void GetName_AttachedProperty1 ()
		{
			TabControl tabControl = new TabControl ();
			TabItem tabItem = new TabItem ();
			CreateAsyncTest (tabControl,
			() => {
				AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (tabItem);

				string textblockName = "Hello world:";
				string nameProperty = "TextBox name";

				TextBlock textblock = new TextBlock ();
				textblock.Text = textblockName;

				tabItem.SetValue (AutomationProperties.NameProperty, nameProperty);
				Assert.AreEqual (string.Empty, peer.GetName (), "GetName #0");

				tabItem.SetValue (AutomationProperties.LabeledByProperty, textblock);
				Assert.AreEqual (textblockName, peer.GetName (), "GetName #1");

				textblock.Text = null;
				Assert.AreEqual (string.Empty, peer.GetName (), "GetName #2");

				textblock.Text = string.Empty;
				Assert.AreEqual (string.Empty, peer.GetName (), "GetName #3");

				tabItem.SetValue (AutomationProperties.NameProperty, null);
				Assert.AreEqual (string.Empty, peer.GetName (), "GetName #4");

				tabItem.SetValue (AutomationProperties.LabeledByProperty, null);
				Assert.AreEqual (string.Empty, peer.GetName (), "GetName #5");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:33,代码来源:TabItemAutomationPeerTest.cs

示例5: GetItemType_AttachedProperty

		public override void GetItemType_AttachedProperty ()
		{
			TabControl tabControl = new TabControl ();
			CreateAsyncTest (tabControl,
			() => {
				TabItem tabItem = new TabItem ();
				AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement (tabItem);

				Assert.AreEqual (string.Empty, peer.GetItemType (), "GetItemType");

				string itemType = "My Item Type";

				tabItem.SetValue (AutomationProperties.ItemTypeProperty, itemType);
				Assert.AreEqual (string.Empty, peer.GetItemType (), "GetItemType #1");

				tabItem.SetValue (AutomationProperties.ItemTypeProperty, null);
				Assert.AreEqual (string.Empty, peer.GetItemType (), "GetItemType #2");
			});
		}
开发者ID:dfr0,项目名称:moon,代码行数:19,代码来源:TabItemAutomationPeerTest.cs


注:本文中的System.Windows.Controls.TabItem.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。