• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Windows.Style类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: StyleItem

        /// <summary>
        /// Initializes a new instance of the <see cref="StyleItem"/> class.
        /// </summary>
        public StyleItem(Style style, FrameworkElement source, string name, string location, StyleScope scope)
        {
            Style = style;
            Name = name;
            Location = location;
            Scope = scope;

            // Setters
            foreach (Setter setter in style.Setters)
            {
                if(setter.Property.Name == "OverridesDefaultStyle" && setter.Value.ToString().ToLower() == "true")
                {
                    OverridesDefaultStyle = true;
                }
                _setterItems.Add(new SetterItem(setter, source));
            }

            // Triggers
            foreach (var trigger in style.Triggers)
            {
                _triggerItems.Add(TriggerItemFactory.GetTriggerItem(trigger, source, TriggerSource.Style ));
            }

            // Ressources
            foreach (var resource in ResourceHelper.GetResourcesRecursively<object>(style.Resources))
            {
                _resourceItems.Add(ResourceItemFactory.CreateResourceItem(resource.Key, resource.Owner, source, ResourceScope.Style));
            }

            GlobalIndex = StyleHelper.GetGlobalIndex(style);
        }
开发者ID:MitchellChu,项目名称:WPF-Inspector,代码行数:34,代码来源:StyleItem.cs


示例2: 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


示例3: Style

        /// <summary>
        ///     Style construction 
        /// </summary>
        /// <param name="targetType">Type in which Style will be applied</param> 
        /// <param name="basedOn">Style to base this Style on</param> 
        public Style(Type targetType, Style basedOn)
        { 
            TargetType = targetType;
            BasedOn = basedOn;

            GetUniqueGlobalIndex(); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:12,代码来源:Style.cs


示例4: CacheStyle

 public static void CacheStyle(Style style, string key)
 {
     if (!Keys.ContainsKey(style))
     {
         Keys.Add(style, key);
     }
 }
开发者ID:JamesTryand,项目名称:snoopwpf,代码行数:7,代码来源:StyleKeyCache.cs


示例5: 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


示例6: 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


示例7: 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


示例8: SetStyleWithType

 public static void SetStyleWithType(this FrameworkElement element, Style style)
 {
     if (element.Style != style && (style == null || style.TargetType != null))
     {
         element.Style = style;
     }
 }
开发者ID:MagicWang,项目名称:WYJ,代码行数:7,代码来源:Extensions.cs


示例9: WhereTabNullNotNullConditionControl

 public WhereTabNullNotNullConditionControl()
 {
     InitializeComponent();
     ComboboxOriginalStyle = this.cmbWhereTabNullNotNullColumns.Style;
     List<string> ListOfLogicalOpreator = new List<string> { "And", "Or" };
     this.cmbWhereTabQueryAndOr.ItemsSource = ListOfLogicalOpreator;
 }
开发者ID:mukeshdepani,项目名称:ParaRD,代码行数:7,代码来源:WhereTabNullNotNullConditionControl.xaml.cs


示例10: ucPlaylistEditor

        public ucPlaylistEditor()
        {
            InitializeComponent();
            rdoArtistSearch.IsChecked = true;
            observablePlaylist = new ObservableCollection<Track>();
            lstPlaylist.ItemsSource = observablePlaylist;

            // for drag and drop reorder of playlist
            Style itemContainerStyle = new Style(typeof(ListBoxItem));
            itemContainerStyle.Setters.Add(new Setter(AllowDropProperty, true));
            itemContainerStyle.Setters.Add(new EventSetter(PreviewMouseMoveEvent, new MouseEventHandler(s_PreviewMouseMove)));
            itemContainerStyle.Setters.Add(new EventSetter(DropEvent, new DragEventHandler(lstPlaylist_Drop)));
            itemContainerStyle.Resources.Add(SystemColors.HighlightBrushKey, Brushes.Transparent);
            itemContainerStyle.Resources.Add(SystemColors.InactiveSelectionHighlightBrushKey, Brushes.Transparent);
            itemContainerStyle.Resources.Add(SystemColors.InactiveSelectionHighlightTextBrushKey, Brushes.White);
            lstPlaylist.ItemContainerStyle = itemContainerStyle;

            try
            {
                sendPlaylistChangesToPlayer = Properties.Settings.Default.SendPlaylistChangesToPlayer;
                chkSendPlaylistToPlayer.IsChecked = sendPlaylistChangesToPlayer;
            }
            catch (Exception)
            {
                sendPlaylistChangesToPlayer = false;
                chkSendPlaylistToPlayer.IsChecked = false;
            }
        }
开发者ID:aljordan,项目名称:WAMP,代码行数:28,代码来源:ucPlaylistEditor.xaml.cs


示例11: TreeGridViewRowPresenter

		static TreeGridViewRowPresenter()
		{
			DefaultSeparatorStyle = new Style(typeof(Rectangle));
			DefaultSeparatorStyle.Setters.Add(new Setter(Shape.FillProperty, SystemColors.ControlLightBrush));
			DefaultSeparatorStyle.Setters.Add(new Setter(UIElement.IsHitTestVisibleProperty, false));
			SeparatorStyleProperty = DependencyProperty.Register("SeparatorStyle", typeof(Style), typeof(TreeGridViewRowPresenter), new UIPropertyMetadata(DefaultSeparatorStyle, SeparatorStyleChanged));
		}
开发者ID:xbadcode,项目名称:Rubezh,代码行数:7,代码来源:TreeGridViewRowPresenter.cs


示例12: OnElementChanged

        protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null)
                return;

            var grid = Control;            
            var textBox = (PhoneTextBox) grid.Children[0];
            var passwordBox = (PasswordBox) grid.Children[1];

            var foregroundColor = Colors.Black;
            var hintColor = Colors.DarkGray;

            var darkBackgroundVisibility = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
            if (darkBackgroundVisibility == Visibility.Visible)
            {
                foregroundColor = Colors.White;
                hintColor = Colors.DarkGray;                
            }
                
            // remove borders and backgrounds in regular mode
            textBox.BorderThickness = new Thickness(0);            
            textBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
            textBox.Background = new SolidColorBrush(Colors.Transparent);
            passwordBox.BorderThickness = new Thickness(0);
            passwordBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
            passwordBox.Background = new SolidColorBrush(Colors.Transparent);

            // Foregrounds
            textBox.Foreground = new SolidColorBrush(foregroundColor);                        
            textBox.SelectionForeground = new SolidColorBrush(foregroundColor);
            passwordBox.Foreground = new SolidColorBrush(foregroundColor);
            passwordBox.SelectionForeground = new SolidColorBrush(foregroundColor);

            // Focus handling
            textBox.GotFocus += (sender, evt) =>
            {
                textBox.Background = new SolidColorBrush(Colors.Transparent);
                textBox.CaretBrush = new SolidColorBrush(foregroundColor);
                passwordBox.Background = new SolidColorBrush(Colors.Transparent);
                passwordBox.CaretBrush = new SolidColorBrush(foregroundColor);

                textBox.ActualHintVisibility = string.IsNullOrWhiteSpace(textBox.Text)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            };

            textBox.TextChanged += (sender, evt) =>
            {
                textBox.ActualHintVisibility = string.IsNullOrWhiteSpace(textBox.Text)
                    ? Visibility.Visible
                    : Visibility.Collapsed;
            };
            
            // Update hint
            var style = new Style {TargetType = typeof (ContentControl)};
            style.Setters.Add(new Setter(System.Windows.Controls.Control.ForegroundProperty, new SolidColorBrush(hintColor)));
            textBox.HintStyle = style;                        
        }
开发者ID:patridge,项目名称:NControl.Controls,代码行数:60,代码来源:ExtendedEntryRenderer.cs


示例13: MainWindow

        public MainWindow()
        {
            InitializeComponent();

            string culture = CfgFile.Get("Lang");
            LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo(culture);
            Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture;

            using (var fs = new FileStream("Theme.xaml", FileMode.Open))
            {
                var dic = (ResourceDictionary)XamlReader.Load(fs);
                Application.Current.MainWindow.Resources.MergedDictionaries.Clear();
                Application.Current.MainWindow.Resources.MergedDictionaries.Add(dic);
            }

            // Wiring up View and ViewModel
            var model = new MainWindowViewModel();
            DataContext = model;

            navigationButtonStyle = (Style)FindResource("NavigationButton");
            navigationButtonSelectedStyle = (Style)FindResource("NavigationButton");
            navigationButtonFirstStyle = (Style)FindResource("NavigationButton");
            navigationButtonFirstSelectedStyle = (Style)FindResource("NavigationButton");

            ProcessFirstRun();
        }
开发者ID:nullkuhl,项目名称:driverGalaxy-release,代码行数:26,代码来源:MainWindow.xaml.cs


示例14: CreateElementStyle

 private static Style CreateElementStyle(DataGrid dataGrid, string bindingPath)
 {
   var baseStyle = dataGrid.FindResource("TextBlockBaseStyle") as Style;
   var style = new Style(typeof(TextBlock), baseStyle);
   AddSetters(style, bindingPath);
   return style;
 }
开发者ID:AhmedRagheb,项目名称:WPF-MVVM-SimpleProject,代码行数:7,代码来源:DataGridChangeBehavior.cs


示例15: SelectTabControl

        public SelectTabControl()
        {

            InitializeComponent();
            DataContext = m_items;
            ComboboxOriginalStyle = this.ComputedColComboBox1.Style;
            ComboboxOriginalStyle = this.ComputedColFunctionComboBox.Style;
            this.ComputedColFunctionComboBox.ItemsSource = Functions.getFunctionNames();
            isValidated = false;
            ColsToSelectAcc.SelectionMode = AccordionSelectionMode.ZeroOrOne;
            RowOriginalBorderBrush = Brushes.White;
            //seting up list ToselectColumFrom
            lstToSelecteColFrom.ItemsSource = _FromSelectedColToCollection;
            //seting up selected list box itemsource
            lstSelectedCol.ItemsSource = _SelectedColCollection;
            //setting computed col listbox
            Column computedCol = new Column();
            computedCol.Name = "";
            computedCol.AliasName = "";
            computedColList.Add(computedCol);
            lstSelectedCol.MouseMove += new MouseEventHandler(lstSelectedCol_MouseMove);
            List<string> ComputedColFormatComboBoxItemSrc = Common.GetColumsFormatList();
            ComputedColFormatComboBoxItemSrc.Insert(0, "Select One");
            ComputedColFormatComboBox.ItemsSource = ComputedColFormatComboBoxItemSrc;
            ComputedColFormatComboBox.SelectedIndex = 0;

        }
开发者ID:mukeshdepani,项目名称:ParaRD,代码行数:27,代码来源:SelectTabControl.xaml.cs


示例16: CreateCellTemplate

        internal static System.Windows.DataTemplate CreateCellTemplate(EntityFieldInfo entityFieldInfo,DataGrid dataGrid)
        {
            DataTemplate dataTemplate = new DataTemplate();
            FrameworkElementFactory contentControl = new FrameworkElementFactory(typeof(ContentControl));
            contentControl.SetBinding(ContentControl.ContentProperty, new Binding());
            Style contentControlStyle = new Style();
            contentControl.SetValue(ContentControl.StyleProperty, contentControlStyle);

            DataTemplate tpl = new DataTemplate();
            if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Color)
            {
                FrameworkElementFactory grid = new FrameworkElementFactory(typeof(Grid));
                Binding binding = CreateBindingOneWay(entityFieldInfo.Path);
                binding.Converter = new StringToBrushConverter();
                grid.SetBinding(Grid.BackgroundProperty, binding);
                tpl.VisualTree = grid;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }
            else
            {
                FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBlock));
                if (entityFieldInfo.ControlType == Infrastructure.Attributes.ControlType.Pr)
                { textBox.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Right); }
                textBox.SetBinding(TextBlock.TextProperty, CreateBindingOneWay(entityFieldInfo.Path));
                tpl.VisualTree = textBox;
                contentControlStyle.Setters.Add(new Setter(ContentControl.ContentTemplateProperty, tpl));
                dataTemplate.VisualTree = contentControl;
            }

            return dataTemplate;
        }
开发者ID:ChampsyGnom,项目名称:GeoPat,代码行数:32,代码来源:DataGridTemplateBuilder.cs


示例17: ImageAnnotation

        private ImageAnnotation(
            Point textLocation,
            Image image,
            Style annontationStyle,
            Style annotationEditorStyle)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            _image = image;
            this.HookImageEvents(true);

            //Size imageSize = _image.RenderSize;
            Size imageSize = new Size(_image.Width, _image.Height);
            if (imageSize.Height == 0 || imageSize.Width == 0)
                throw new ArgumentException("image has invalid dimensions");

            // Determine the relative location of the TextBlock.
            _horizPercent = textLocation.X / imageSize.Width;
            _vertPercent = textLocation.Y / imageSize.Height;

            // Create the adorner which displays the annotation.
            _adorner = new ImageAnnotationAdorner(
                this,
                _image,
                annontationStyle,
                annotationEditorStyle,
                textLocation);

            this.InstallAdorner();
        }
开发者ID:carlif,项目名称:Delta-Drawing,代码行数:31,代码来源:ImageAnnotation.cs


示例18: Activate

 /// <summary>
 /// Activate this behavior for all ScatterViewItems
 /// </summary>
 public static void Activate()
 {
     // sets style for all ScatterViewItems
     Style sviStyle = new Style(typeof(ScatterViewItem));           
     sviStyle.Setters.Add(new Setter(CustomTopmostBehavior.IsEnabledProperty, true));
     Application.Current.Resources.Add(typeof(ScatterViewItem), sviStyle);
 }
开发者ID:madebysoren,项目名称:NooSphere,代码行数:10,代码来源:CustomTopmostBehavior.cs


示例19: AddSessionsHubTiles

        private void AddSessionsHubTiles(string name , string session)
        {
            /*
            HubTile hubTile = new HubTile();
            hubTile.Title="Track";
            hubTile.Margin =new Thickness(14);
            hubTile.Notification="JUAN";
            hubTile.DisplayNotification=true;
            hubTile.Background = new SolidColorBrush(Colors.Cyan);
            hubTile.Foreground = new SolidColorBrush(Colors.Black);
            hubTile.GroupTag="Food";
            hubTile.Size=TileSize.Medium;*/

            SessionButton b = new SessionButton();
            if (name == "")
            {
                b.Content = "No\nname\nSession:\n" + session;
            }
            else
            {
                b.Content = "Name:\n"+name+"\nSession:\n" + session;
            }
            b.Height = 175;
            b.Width = 175;
            Style s = new Style();
            b.Style = (Style)this.Resources["ButtonStyleViewerHistory"];
            b.Session = session;
            b.Click += b_Click;

            LastSessionsStack.Children.Add(b);
        }
开发者ID:juank334,项目名称:TrackMe,代码行数:31,代码来源:PanoramaPage.xaml.cs


示例20: GridViewRowPresenterWithGridLines

 static GridViewRowPresenterWithGridLines()
 {
     DefaultSeparatorStyle = new Style(typeof(Rectangle));
     DefaultSeparatorStyle.Setters.Add(new Setter(Shape.FillProperty, SystemColors.ControlLightBrush));
     SeparatorStyleProperty = DependencyProperty.Register("SeparatorStyle", typeof(Style), typeof(GridViewRowPresenterWithGridLines),
                                                             new UIPropertyMetadata(DefaultSeparatorStyle, SeparatorStyleChanged));
 }
开发者ID:NALSS,项目名称:epiinfo-82474,代码行数:7,代码来源:GridViewRowPresenterWithGridLines.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Windows.TextDecorationCollection类代码示例发布时间:2022-05-26
下一篇:
C# Windows.StartupEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap