public static void SetIconVisibility(System.Windows.Controls.TabItem obj, Visibility value) => obj.SetValue(IconVisibilityProperty, value);
 public static void SetIconForeground(System.Windows.Controls.TabItem obj, Brush value) => obj.SetValue(IconForegroundProperty, value);
 public static void SetIconKind(System.Windows.Controls.TabItem obj, PackIconMaterialKind value) => obj.SetValue(IconKindProperty, value);
 public static void SetHeaderFontSize(System.Windows.Controls.TabItem obj, double value) => obj.SetValue(HeaderFontSizeProperty, value);
        /// <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;
        }
예제 #6
0
		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");
			});
		}
예제 #7
0
		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");
			});
		}
예제 #8
0
		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");
			});
		}
예제 #9
0
		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");
			});
		}