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


C# SolidColorBrush.SetValue方法代码示例

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


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

示例1: BrushWithTwoParents_TwoSubtrees_SetOneFirst

		public void BrushWithTwoParents_TwoSubtrees_SetOneFirst()
		{
			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");

			var first = (Canvas)XamlReader.Load(@"<Canvas xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (Canvas)XamlReader.Load(@"<Canvas xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			first.Children.Add(new Canvas { Background = brush });
			second.Children.Add(new Canvas { Background = brush });

			Assert.AreSame(brush, first.FindName("Test"), "#1");
			Assert.IsNull(second.FindName("Test"), "#2");
		}
开发者ID:dfr0,项目名称:moon,代码行数:14,代码来源:LogicalTreeTest.cs

示例2: UseTwice

		public void UseTwice()
		{
			string name = "SuperSecretBrush";
			Brush b1 = new SolidColorBrush();
			b1.SetValue(FrameworkElement.NameProperty, name);

			var g1 = new Grid { Name = "g1", Background = b1 };
			var g2 = new Grid { Name = "g2", Background = b1 };

			TestPanel.Children.Add(g1);
			Assert.IsNull(TestPanel.FindName(name), "#1");

			TestPanel.Children.Add(g2);
			Assert.IsNull(TestPanel.FindName(name), "#2");
		}
开发者ID:kangaroo,项目名称:moon,代码行数:15,代码来源:BrushTest.cs

示例3: UseTwice_ThenOnce

		public void UseTwice_ThenOnce()
		{
			string name = "SuperSecretBrush";
			Brush brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, name);

			var g1 = new Grid { Name = "g1", Background = brush };
			var g2 = new Grid { Name = "g2", Background = brush };

			TestPanel.Children.Add(g1);
			Assert.IsNull(TestPanel.FindName(name), "#1");

			g2.Background = null;
			Assert.IsNull(TestPanel.FindName(name), "#2");

			TestPanel.Children.Clear();
			TestPanel.Children.Add(g1);
			Assert.AreSame(brush, TestPanel.FindName(name), "#3");
		}
开发者ID:kangaroo,项目名称:moon,代码行数:19,代码来源:BrushTest.cs

示例4: BrushWithTwoParents_UnregisterWrongObject

		public void BrushWithTwoParents_UnregisterWrongObject()
		{
			// Create two brushes with the same name. Put one of them in both
			// textboxes and the other just in the second textbox. See if clearing
			// the first brush in the second textbox will unregister the name of the
			// second brush from the second textbox.
			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");
			
			var secondBrush = new SolidColorBrush();
			secondBrush.SetValue(FrameworkElement.NameProperty, "Test");

			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			first.Foreground = brush;
			second.Foreground = brush;

			second.Background = secondBrush;
			second.Foreground = null;

			Assert.AreSame(secondBrush, second.FindName("Test"), "#1");
		}
开发者ID:dfr0,项目名称:moon,代码行数:23,代码来源:LogicalTreeTest.cs

示例5: BrushWithThreeParents_ComplexParenting_AlternateNull

		public void BrushWithThreeParents_ComplexParenting_AlternateNull()
		{
			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");

			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var third = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var fourth = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			first.Foreground = brush;
			Assert.AreSame(brush, first.FindName("Test"), "#1a");
			Assert.IsNull(second.FindName("Test"), "#2a");
			Assert.IsNull(third.FindName("Test"), "#3a");
			Assert.IsNull(fourth.FindName("Test"), "#4a");

			second.Foreground = brush;
			first.Foreground = null;
			Assert.AreSame(brush, first.FindName("Test"), "#1b");
			Assert.IsNull(second.FindName("Test"), "#2b");
			Assert.IsNull(third.FindName("Test"), "#3b");
			Assert.IsNull(fourth.FindName("Test"), "#4b");

			third.Foreground = brush;
			second.Foreground = null;
			Assert.AreSame(brush, first.FindName("Test"), "#1c");
			Assert.IsNull(second.FindName("Test"), "#2c");
			Assert.IsNull(third.FindName("Test"), "#3c");
			Assert.IsNull(fourth.FindName("Test"), "#4c");

			fourth.Foreground = brush;
			third.Foreground = null;
			Assert.AreSame(brush, first.FindName("Test"), "#5a");
			Assert.IsNull(second.FindName("Test"), "#5b");
			Assert.IsNull(third.FindName("Test"), "#5c");
			Assert.IsNull(fourth.FindName("Test"), "#5d");

			fourth.Foreground = null;
			Assert.AreSame(brush, first.FindName("Test"), "#6a");
			Assert.IsNull(second.FindName("Test"), "#6b");
			Assert.IsNull(third.FindName("Test"), "#6c");
			Assert.IsNull(fourth.FindName("Test"), "#6d");
		}
开发者ID:dfr0,项目名称:moon,代码行数:43,代码来源:LogicalTreeTest.cs

示例6: BrushWithThreeParents_NullInReverseOrder

		public void BrushWithThreeParents_NullInReverseOrder()
		{
			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");

			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var third = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			first.Foreground = brush;
			second.Foreground = brush;
			third.Foreground = brush;

			third.Foreground = null;
			second.Foreground = null;
			first.Foreground = null;

			Assert.IsNull(first.FindName("Test"), "#1");
			Assert.IsNull(second.FindName("Test"), "#1");
			Assert.IsNull(third.FindName("Test"), "#1");
		}
开发者ID:dfr0,项目名称:moon,代码行数:21,代码来源:LogicalTreeTest.cs

示例7: BrushWithThreeParents_NullAll_ThenPutInNewNamescope

		public void BrushWithThreeParents_NullAll_ThenPutInNewNamescope()
		{
			// Create two TextBlocks with unique namescopes and add the same brush to  both.
			// Then null the properties and add the brush to a third namescope to see if it
			// is registered there.
			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");

			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var third = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var fourth = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			first.Foreground = null;
			second.Foreground = null;
			third.Foreground = null;
			fourth.Foreground = null;

			first.Foreground = brush;
			second.Foreground = brush;
			third.Foreground = brush;

			first.Foreground = null;
			second.Foreground = null;
			third.Foreground = null;

			fourth.Foreground = brush;
			Assert.AreSame(brush, fourth.FindName("Test"), "#1");
		}
开发者ID:dfr0,项目名称:moon,代码行数:29,代码来源:LogicalTreeTest.cs

示例8: BrushWithTwoParents_NullBoth_NamescopeClash

		public void BrushWithTwoParents_NullBoth_NamescopeClash()
		{
			// Create two TextBlocks with unique namescopes and add the same brush to  both
			// If we then clear the two Foregrounds by setting them to null, the name is never
			// unregistered from the first namescope so if we try to reuse the name we blow up.
			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");
			first.Foreground = brush;
			second.Foreground = brush;

			first.Foreground = null;
			second.Foreground = null;

			brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");

			Assert.Throws<ArgumentException>(() => first.Foreground = brush, "#1");
		}
开发者ID:dfr0,项目名称:moon,代码行数:21,代码来源:LogicalTreeTest.cs

示例9: BrushWithTwoParents_NullBoth

		public void BrushWithTwoParents_NullBoth()
		{
			// Create two TextBlocks with unique namescopes and add the same brush to  both
			// By setting the Foreground properties to null, the brush is still in the namescope
			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");
			first.Foreground = brush;
			second.Foreground = brush;

			first.Foreground = null;
			second.Foreground = null;
			Assert.AreSame(brush, first.FindName("Test"), "#1");
			Assert.IsNull(second.FindName("Test"), "#2");
		}
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:LogicalTreeTest.cs

示例10: BrushWithTwoParents_NullSecond_ThenPutInNewNamescope

		public void BrushWithTwoParents_NullSecond_ThenPutInNewNamescope()
		{
			// Create two TextBlocks with unique namescopes and add the same brush to  both
			var first = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			var second = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");

			var brush = new SolidColorBrush();
			brush.SetValue(FrameworkElement.NameProperty, "Test");
			first.Foreground = brush;
			second.Foreground = brush;

			second.Foreground = null;

			var third = (TextBox)XamlReader.Load(@"<TextBox xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" />");
			third.Foreground = brush;
			Assert.IsNull(third.FindName("Test"), "#1");
		}
开发者ID:dfr0,项目名称:moon,代码行数:17,代码来源:LogicalTreeTest.cs


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