コード例 #1
0
		public void FindParentControl_ParentDoesNotExists()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				StackPanel intermediateStackPanel = visual.IntermediatePanel;

				TabControl g = intermediateStackPanel.FindParentControl<TabControl>();

				Assert.IsNull(g);
			});
		}
コード例 #2
0
		public void FindParentControl_ParentExists()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				StackPanel intermediateStackPanel = visual.IntermediatePanel;

				StackPanel sp = intermediateStackPanel.FindParentControl<StackPanel>();

				Assert.IsTrue(sp != null && sp.Name == "RootPanel");
			});
		}
コード例 #3
0
		public void FindChildControl_IndexTooGreat()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				TextBox tb = visual.FindChildControl<TextBox>(4);
				Assert.IsNull(tb);
			});
		}
コード例 #4
0
		public void FindChildControl_IndexLessThanZero()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				TextBox tb = visual.FindChildControl<TextBox>(-1);
				Assert.IsTrue(tb != null && tb.Text == "TextBox 1");
			});
		}
コード例 #5
0
		public void FindChildControl_FindNonExistentControl()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				//Attempt to find first, implicit
				TabControl tc = visual.FindChildControl<TabControl>();
				Assert.IsNull(tc);

				//Attempt to find first, explicit
				tc = visual.FindChildControl<TabControl>(0);
				Assert.IsNull(tc);

				//Attempt to find other than first
				tc = visual.FindChildControl<TabControl>(2);
				Assert.IsNull(tc);

			});
		}
コード例 #6
0
		public void FindChildControl_FindFirst()
		{
			ThreadRunner.RunInSTA(delegate
			{
				DependencyObjectExtensionsTestVisual visual = new DependencyObjectExtensionsTestVisual();
				RenderUtility.RenderVisual(visual);

				//Assume first element
				TextBox tb = visual.FindChildControl<TextBox>();
				Assert.IsTrue(tb != null && tb.Text == "TextBox 1");

				//Explicitly findfirst element
				tb = visual.FindChildControl<TextBox>(0);
				Assert.IsTrue(tb != null && tb.Text == "TextBox 1");
			});
		}