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


C# Windows.Setter类代码示例

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


Setter类属于System.Windows命名空间,在下文中一共展示了Setter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ButtonBarControl

        public ButtonBarControl(WebcamControl element)
        {
            InitializeComponent();
            this.parent = element;
            this.Name = "buttonBar";
            int i;

            buttons=new Button[numberOfButtons];
            double buttonSpace = parent.WebcamImage.ActualWidth / numberOfButtons;

            Style style = new Style(typeof(Button));
            style.Setters.Add(new Setter { Property = OverridesDefaultStyleProperty, Value = true });

            Setter templateSetter = new Setter();
            templateSetter.Property = TemplateProperty;

            ControlTemplate controlTemplate = new ControlTemplate(typeof(Button));

            FrameworkElementFactory fact = new FrameworkElementFactory(typeof(Border));

            controlTemplate.VisualTree = fact;

            fact.Name = "Border";
            //fact.SetValue(Border.BorderThicknessProperty, new Thickness(1));
            //fact.SetValue(Border.CornerRadiusProperty, new CornerRadius(2));
            fact.SetValue(Border.BackgroundProperty,new TemplateBindingExtension(Button.BackgroundProperty));
            //fact.SetValue(Border.BorderBrushProperty, Brushes.Aquamarine);

            Trigger triggerIsMouseOver = new Trigger { Property = Border.IsMouseOverProperty, Value = true };

            Binding b = new Binding();
            b.RelativeSource = new RelativeSource(RelativeSourceMode.TemplatedParent);
            b.Path = new PropertyPath(Button.BorderBrushProperty);

            Setter setter = new Setter(Border.BackgroundProperty, b, "Border");

            triggerIsMouseOver.Setters.Add(setter);

            controlTemplate.Triggers.Add(triggerIsMouseOver);
            templateSetter.Value = controlTemplate;

            style.Setters.Add(templateSetter);

            for (i = 0; i < numberOfButtons; i++)
            {
                buttons[i] = new Button();
                //buttons[i].Foreground = new ImageBrush(new BitmapImage(new Uri("test.png", UriKind.Relative)));
                buttons[i].Style = style;
                buttons[i].Background = new ImageBrush(new BitmapImage(new Uri((i+1)+"1.png", UriKind.Relative)));
                buttons[i].BorderBrush = new ImageBrush(new BitmapImage(new Uri((i+1)+"2.png", UriKind.Relative)));
                //buttons[i].Content = "Button" + i;
                buttons[i].Width = (buttonSpace-0.1*buttonSpace);
                buttons[i].Height = 100 - 20;
                buttons[i].Margin = new Thickness(0.05*buttonSpace, 10, 0.05*buttonSpace, 0);
                buttons[i].Click += new RoutedEventHandler(ButtonBar_Click);
                buttonStack.Children.Add(buttons[i]);

            }
        }
开发者ID:kovacshuni,项目名称:slrt,代码行数:59,代码来源:ButtonBarControl.xaml.cs

示例2: StyleSelectionMenuItemList

        public StyleSelectionMenuItemList()
        {
            ItemsSource = ItemsSource = AvailableStyles.Instance;

            var checkableMenuItemStyle = new Style { TargetType = typeof(MenuItem) };

            var headerBinding = new Binding();
            var headerSetter = new Setter(HeaderProperty, headerBinding);
            checkableMenuItemStyle.Setters.Add(headerSetter);

            var isCheckableSetter = new Setter(IsCheckableProperty, true);
            checkableMenuItemStyle.Setters.Add(isCheckableSetter);

            ICommand command = new RelayCommand(SelectStyle);
            var commandSetter = new Setter(CommandProperty, command);
            checkableMenuItemStyle.Setters.Add(commandSetter);

            var commandParamBinding = new Binding();
            var commandParamSetter = new Setter(CommandParameterProperty, commandParamBinding);
            checkableMenuItemStyle.Setters.Add(commandParamSetter);

            var isCheckedMultiBinding = new MultiBinding { Converter = new MultiValueStringsMatchConverter(), Mode = BindingMode.OneWay };
            isCheckedMultiBinding.Bindings.Add(new Binding { Mode = BindingMode.OneWay });
            isCheckedMultiBinding.Bindings.Add(new Binding("SelectedStyle") { Source = AvailableStyles.Instance, Mode = BindingMode.OneWay });
            var isCheckedSetter = new Setter(IsCheckedProperty, isCheckedMultiBinding);
            checkableMenuItemStyle.Setters.Add(isCheckedSetter);

            Resources.Add(typeof(MenuItem), checkableMenuItemStyle);
        }
开发者ID:ChronosWS,项目名称:WPFSharp.Globalizer,代码行数:29,代码来源:StyleSelectionMenuItemList.cs

示例3: CreateTest

		public void CreateTest ()
		{
			Setter s = new Setter (UIElement.OpacityProperty, 2.0);

			Assert.AreEqual (UIElement.OpacityProperty, s.Property);
			Assert.AreEqual (2.0, s.Value);
		}
开发者ID:dfr0,项目名称:moon,代码行数:7,代码来源:SetterTest.cs

示例4: SelectStyle

        public override Style SelectStyle(object item, DependencyObject container)
        {
            Style style = new Style {
                TargetType = typeof(ListBoxItem)
            };
            Setter setter = new Setter {
                Property = Control.BackgroundProperty
            };
            ListBox box = ItemsControl.ItemsControlFromItemContainer(container) as ListBox;
            switch (box.ItemContainerGenerator.IndexFromContainer(container))
            {
                case 0:
                    setter.Value = Brushes.LightBlue;
                    break;

                case 1:
                    setter.Value = Brushes.Green;
                    break;

                default:
                    setter.Value = Brushes.SaddleBrown;
                    break;
            }
            style.Setters.Add(setter);
            return style;
        }
开发者ID:netonjm,项目名称:WindowsPhone,代码行数:26,代码来源:ListViewItemStyleSelector.cs

示例5: FindResource

        object FindResource(object resourceKey)
        {
            // NOTE: This code depends on internal implementation details of WPF and 
            // might break in a future release of the platform.  Use at your own risk!

            var resourceReferenceExpression =
                new DynamicResourceExtension(resourceKey).ProvideValue(null)
                as Expression;

            MethodInfo getValue = typeof(Expression).GetMethod(
                "GetValue",
                BindingFlags.Instance | BindingFlags.NonPublic);

            object result = getValue.Invoke(
                resourceReferenceExpression,
                new object[] { this, DummyProperty });

            // Either we do not have an inheritance context or the  
            // requested resource does not exist, so return null.
            if (result == DependencyProperty.UnsetValue)
                return null;

            // The requested resource was found, so we will receive a 
            // DeferredResourceReference object as a result of calling 
            // GetValue.  The only way to resolve that to the actual 
            // resource, without using reflection, is to have a Setter's 
            // Value property unwrap it for us.
            var deferredResourceReference = result;
            Setter setter = new Setter(DummyProperty, deferredResourceReference);
            return setter.Value;
        }
开发者ID:jimgraham,项目名称:WPF.JoshSmith,代码行数:31,代码来源:ResourceKeyToResourceConverter.cs

示例6: Window_Loaded

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GridView myGridView = new GridView();
            myGridView.AllowsColumnReorder = true;

            //Collapse the header
            Style collapsedHeaderStyle = new Style();
            Setter collapsedHeaderSetter = new Setter();

            collapsedHeaderSetter.Property = VisibilityProperty;
            collapsedHeaderSetter.Value = Visibility.Collapsed;
            collapsedHeaderStyle.Setters.Add(collapsedHeaderSetter);

            myGridView.ColumnHeaderContainerStyle = collapsedHeaderStyle;

            for (int i = 0; i < control.XSize; i++)
            {
                GridViewColumn col = new GridViewColumn();
                col.DisplayMemberBinding = new Binding("Column[" + i.ToString() + "]");
                col.Width = 30;
                myGridView.Columns.Add(col);
            }

            listView.View = myGridView;
            listView.DataContext = control.AgentCollection;
        }
开发者ID:mskim1997,项目名称:OriginalProject,代码行数:26,代码来源:Window1.xaml.cs

示例7: LabelTextBox

        public LabelTextBox()
        {
            this.AcceptsReturn = true;
            this.FontWeight = FontWeights.Bold;
            this.BorderThickness = new Thickness(0);

            Setter borderSetter = new Setter();
            borderSetter.Property = TextBox.BorderThicknessProperty;
            borderSetter.Value = new Thickness(0);

            Trigger readOnlyTrigger = new Trigger();
            readOnlyTrigger.Property = TextBox.IsReadOnlyProperty;
            readOnlyTrigger.Value = true;
            readOnlyTrigger.Setters.Add(borderSetter);

            Setter borderFocusSetter = new Setter();
            borderFocusSetter.Property = TextBox.BorderThicknessProperty;
            borderFocusSetter.Value = new Thickness(0);

            Trigger focusTrigger = new Trigger();
            focusTrigger.Property = TextBox.IsFocusedProperty;
            focusTrigger.Value = true;
            focusTrigger.Setters.Add(borderFocusSetter);

            Style style = new Style();
            style.Triggers.Add(readOnlyTrigger);
            style.Triggers.Add(focusTrigger);

            this.Style = style;
            this.SnapsToDevicePixels = true;
        }
开发者ID:Dr1N,项目名称:Whiteboard,代码行数:31,代码来源:LabelTextBox.cs

示例8: TestImplicitStyleRectangle_styleInRectangleDictionary

		public void TestImplicitStyleRectangle_styleInRectangleDictionary ()
		{
			Style rectStyle = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle.Setters.Add (setter);

			Rectangle r = new Rectangle ();

			Assert.IsTrue (Double.IsNaN (r.Width), "1");

			r.Resources.Add (typeof (Rectangle), rectStyle);

			Assert.AreEqual (100.0, r.Width, "2");

			CreateAsyncTest (r,  () => {
					Assert.AreEqual (100.0, r.Width, "3");

					//setter.Value = 200.0;
					//Assert.AreEqual (200.0, r.Width, "4");

					rectStyle.Setters.Remove (setter);

					Assert.AreEqual (100.0, r.Width, "5");
				});
		}
开发者ID:dfr0,项目名称:moon,代码行数:25,代码来源:StyleTest_Implicit.cs

示例9: GetResourceDictionary

        public ResourceDictionary GetResourceDictionary()
        {
            var dict = new ResourceDictionary
            {
                Source = new Uri(GetThemePath(UserSettingStorage.Instance.Theme), UriKind.Absolute)
            };

            Style queryBoxStyle = dict["QueryBoxStyle"] as Style;
            if (queryBoxStyle != null)
            {
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.QueryBoxFont)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStyle)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontWeight)));
                queryBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.QueryBoxFontStretch)));
            }

            Style resultItemStyle = dict["ItemTitleStyle"] as Style;
            Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style;
            Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style;
            Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style;
            if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null)
            {
                Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(UserSettingStorage.Instance.ResultItemFont));
                Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStyle));
                Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontWeight));
                Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(UserSettingStorage.Instance.ResultItemFontStretch));

                Setter[] setters = new Setter[] { fontFamily, fontStyle, fontWeight, fontStretch };
                Array.ForEach(new Style[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
            }

            return dict;
        }
开发者ID:dstiert,项目名称:bloop,代码行数:33,代码来源:Theme.cs

示例10: ZoomableInlineAdornment

        public ZoomableInlineAdornment(UIElement content, ITextView parent) {
            _parent = parent;
            Debug.Assert(parent is IInputElement);
            Content = new Border { BorderThickness = new Thickness(1), Child = content, Focusable = true };

            _zoom = 1.0;             // config.GetConfig().Repl.InlineMedia.MaximizedZoom
            _zoomStep = 0.25;        // config.GetConfig().Repl.InlineMedia.ZoomStep
            _minimizedZoom = 0.25;   // config.GetConfig().Repl.InlineMedia.MinimizedZoom
            _widthRatio = 0.67;      // config.GetConfig().Repl.InlineMedia.WidthRatio
            _heightRatio = 0.5;      // config.GetConfig().Repl.InlineMedia.HeightRatio

            _isResizing = false;
            UpdateSize();

            GotFocus += OnGotFocus;
            LostFocus += OnLostFocus;

            ContextMenu = MakeContextMenu();

            var trigger = new Trigger { Property = Border.IsFocusedProperty, Value = true };
            var setter = new Setter { Property = Border.BorderBrushProperty, Value = SystemColors.ActiveBorderBrush };
            trigger.Setters.Add(setter);

            var style = new Style();
            style.Triggers.Add(trigger);
            MyContent.Style = style;
        }
开发者ID:CforED,项目名称:Node.js-Tools-for-Visual-Studio,代码行数:27,代码来源:ZoomableInlineAdornment.cs

示例11: TestImplicitStyleRectangle_multipleImplicitStylesInVisualTree

		public void TestImplicitStyleRectangle_multipleImplicitStylesInVisualTree ()
		{
			Style rectStyle1 = new Style { TargetType = typeof (Rectangle) };
			Setter setter = new Setter (FrameworkElement.WidthProperty, 100.0);
			rectStyle1.Setters.Add (setter);

			Style rectStyle2 = new Style { TargetType = typeof (Rectangle) };
			setter = new Setter (FrameworkElement.HeightProperty, 100.0);
			rectStyle2.Setters.Add (setter);

			Rectangle r = new Rectangle ();
			r.Resources.Add (typeof (Rectangle), rectStyle1);

			Canvas c = new Canvas ();
			c.Resources.Add (typeof (Rectangle), rectStyle2);

			c.Children.Add (r);

			Assert.IsTrue (Double.IsNaN (r.Height), "1");

			CreateAsyncTest (c,  () => {
					Assert.AreEqual (100.0, r.Width, "2");
					Assert.IsTrue (Double.IsNaN (r.Height), "3");

					r.Resources.Remove (typeof (Rectangle));

					Assert.AreEqual (100.0, r.Height, "4");
					Assert.IsTrue (Double.IsNaN (r.Width), "5");
				});
		}
开发者ID:dfr0,项目名称:moon,代码行数:30,代码来源:StyleTest_Implicit.cs

示例12: AlternatingListBoxBackground

        public AlternatingListBoxBackground(Color color1, Color color2)
        {
            var setter = new Setter();
            setter.Property = ListBoxItem.BackgroundProperty;
            setter.Value = new SolidColorBrush(color1);

            var trigger = new Trigger();
            trigger.Property = ItemsControl.AlternationIndexProperty;
            trigger.Value = 0;
            trigger.Setters.Add(setter);

            var setter2 = new Setter();
            setter2.Property = ListBoxItem.BackgroundProperty;
            setter2.Value = new SolidColorBrush(color2);

            var trigger2 = new Trigger();
            trigger2.Property = ItemsControl.AlternationIndexProperty;
            trigger2.Value = 1;
            trigger2.Setters.Add(setter2);

            var listBoxStyle = new Style(typeof(ListBoxItem));
            listBoxStyle.Triggers.Add(trigger);
            listBoxStyle.Triggers.Add(trigger2);

            _listBoxStyle = listBoxStyle;
        }
开发者ID:Danmer,项目名称:uberdemotools,代码行数:26,代码来源:ListBoxHelper.cs

示例13: CreateSetter

 private static SetterBase CreateSetter(EntityFieldInfo fieldInfo, IDataService dataService, GenericDataListState state, bool? isLocked, FrameworkElement element)
 {
     Setter setter = new Setter();
     setter.Property = ContentControl.ContentTemplateProperty;
     setter.Value = DataControlTemplateBuilder.CreateTemplate(fieldInfo, dataService,  state, isLocked,element);
     return setter;
 }
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:7,代码来源:DataControlTemplateBuilder.cs

示例14: Defaults

		public void Defaults ()
		{
			Setter s = new Setter ();
			Assert.IsNull (s.Property, "Property");
			Assert.IsNull (s.Value, "Value");
			// SetterBase (can't be tested indivisually since the type has no visible ctor)
			Assert.IsFalse (s.IsSealed, "IsSealed");
		}
开发者ID:dfr0,项目名称:moon,代码行数:8,代码来源:SetterTest.cs

示例15: CopyTo

    public void CopyTo(Setter[] array, int arrayIndex)
    {
      if (array == null)
      {
        throw new ArgumentNullException("array");
      }

      List.CopyTo(array, arrayIndex);
    }
开发者ID:npcomplete111,项目名称:MediaPortal-1,代码行数:9,代码来源:SetterBaseCollection.cs


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