Inheritance: DependencyObject, IStyle
コード例 #1
0
 protected override Style SelectStyleCore(object item,
     DependencyObject container)
 {
     Style st = new Style();
     st.TargetType = typeof(ListViewItem);
     Setter backGroundSetter = new Setter();
     backGroundSetter.Property = ListViewItem.BackgroundProperty;
     ListView listView =
         ItemsControl.ItemsControlFromItemContainer(container)
           as ListView;
     int index =
         listView.IndexFromContainer(container);
     if (index % 2 == 0)
     {
         backGroundSetter.Value = (Color)Application.Current.Resources["SystemBackgroundAltHighColor"];
     }
     else
     {
         backGroundSetter.Value = (Color)Application.Current.Resources["SystemAltHighColor"];
     }
     st.Setters.Add(backGroundSetter);
     Setter paddingSetter = new Setter();
     paddingSetter.Property = ListViewItem.PaddingProperty;
     paddingSetter.Value = 0;
     st.Setters.Add(paddingSetter);
     Setter alignSetter = new Setter();
     alignSetter.Property = ListViewItem.HorizontalContentAlignmentProperty;
     alignSetter.Value = "Stretch";
     st.Setters.Add(alignSetter);
     return st;
 }
コード例 #2
0
ファイル: EditableTextBlock.cs プロジェクト: wnf0000/Eto
        public EditableTextBlock()
        {
            var textBox = new FrameworkElementFactory(typeof(TextBox));

            textBox.SetValue(Control.PaddingProperty, new Thickness(1));             // 1px for border
            textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
            textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
            textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
            textBox.SetBinding(TextBox.TextProperty, new Windows.UI.Xaml.Data.Binding("Text")
            {
                Source = this, Mode = BindingMode.TwoWay
#if TODO_XAML
                , UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
#endif
            });
            var editTemplate = new DataTemplate {
                VisualTree = textBox
            };

            var textBlock = new FrameworkElementFactory(typeof(TextBlock));
            textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
            textBlock.AddHandler(UIElement.PointerPressedEvent, (s, e) => {
                PointerPoint pt;
                if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse &&
                    (pt = e.GetCurrentPoint(textBlock) != null) &&
#if TODO_XAML
                    e.ClickCount >= 2 &&
#endif
                    pt.Properties.IsLeftButtonPressed)
                {
                    IsInEditMode = true;
                    e.Handled    = true;
                }
            });
            textBlock.SetBinding(TextBlock.TextProperty, new Windows.UI.Xaml.Data.Binding("Text")
            {
                Source = this
            });
            var viewTemplate = new DataTemplate {
                VisualTree = textBlock
            };

            var style   = new Windows.UI.Xaml.Style(typeof(EditableTextBlock));
            var trigger = new Trigger {
                Property = IsInEditModeProperty, Value = true
            };
            trigger.Setters.Add(new Setter {
                Property = ContentTemplateProperty, Value = editTemplate
            });
            style.Triggers.Add(trigger);

            trigger = new Trigger {
                Property = IsInEditModeProperty, Value = false
            };
            trigger.Setters.Add(new Setter {
                Property = ContentTemplateProperty, Value = viewTemplate
            });
            style.Triggers.Add(trigger);
            Style = style;
        }
コード例 #3
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value == null) return null;

            var resourceKey = value.ToString();
            var resource = Application.Current.Resources[resourceKey] as Style;
            if (resource != null)
            {
                var style = new Style();
                style.BasedOn = resource.BasedOn;
                style.TargetType = resource.TargetType;
                foreach (var setter in resource.Setters)
                {
                    var s = setter as Setter;
                    if (s != null)
                    {
                        var g = s.Value as PathGeometry;
                        if (g != null)
                        {
                            style.Setters.Add(new Setter(s.Property, CloneDeep(g)));
                        }
                        else
                        {
                            style.Setters.Add(new Setter(s.Property, s.Value));
                        }

                    }
                }

                return style;
            }

            return null;
        }
コード例 #4
0
 /// <summary>
 /// This method will change the style of each AppBarButton to use a green foreground color
 /// </summary>
 /// <param name="panel"></param>
 private void ColorButtons(StackPanel panel)
 {
     int count = 0;
     foreach (var item in panel.Children)
     {
         // For AppBarButton, change the style
         if (item.GetType() == typeof(AppBarButton))
         {
             if (count == 0)
             {
                 originalButtonStyle = ((AppBarButton)item).Style;
             }
             ((AppBarButton)item).Style = rootPage.Resources["GreenAppBarButtonStyle"] as Style;
             count++;
         }
         else
         {
             // For AppBarSeparator(s), just change the foreground color
             if (item.GetType() == typeof(AppBarSeparator))
             {
                 originalSeparatorBrush = ((AppBarSeparator)item).Foreground;
                 ((AppBarSeparator)item).Foreground = new SolidColorBrush(Color.FromArgb(255, 90, 200, 90));
             }
         }
     }
 }
コード例 #5
0
        private void CustomTabRenderer_ElementChanged(object sender, VisualElementChangedEventArgs e)
        {
            if (Control != null)
            {
                /*Control.HeaderTemplate = (Windows.UI.Xaml.DataTemplate)
                 *  ((Windows.UI.Xaml.Setter)((Windows.UI.Xaml.Style)App.Current.Resources["DefaultPivotHeaderItemStyle"]).Setters[12]).Value;*/
                //Control.Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["DefaultPivotHeaderItemStyle"];

                Windows.UI.Xaml.Style pivotStyle = (Windows.UI.Xaml.Style)App.Current.Resources["MyPivotStyle"];
                Control.Template = (Windows.UI.Xaml.Controls.ControlTemplate)
                                       ((Windows.UI.Xaml.Setter)(pivotStyle).Setters[5]).Value;

                //Background = "#F2FAFE"

                Control.HeaderTemplate = (Windows.UI.Xaml.DataTemplate)App.Current.Resources["PivotHeaderTemplate"];

                //GetStyledTitleTemplate();

                //((Windows.UI.Xaml.Controls.ItemsControl) Control.Items[0]).
                //Control.Template = (Windows.UI.Xaml.Controls.ControlTemplate)App.Current.Resources["DefaultPivotStyle"];
                //Control.Style = (Windows.UI.Xaml.Style)App.Current.Resources["DefaultPivotStyle"];
                //Control.Template = (Windows.UI.Xaml.Controls.ControlTemplate)App.Current.Resources["Windows.UI.Xaml.Controls.Pivot"];
                //Control.ItemContainerStyle = ((Windows.UI.Xaml.Style)App.Current.Resources["DefaultPivotItemStyle"]);

                /*foreach (var x in App.Current.Resources) {
                 *  Debug.WriteLine(x.Key);
                 * }*/

                //Control.Style = (Windows.UI.Xaml.Style)App.Current.Resources["DefaultPivotHeaderItemStyle"];
            }
        }
コード例 #6
0
        private void ShowRightClickMenu(object sender, RoutedEventArgs e)
        {
            string menu = IsServer ? "ServerContextMenu" : "ChannelContextMenu";

            var RightClick = this.Resources[menu] as MenuFlyout;

            if (e is RightTappedRoutedEventArgs)
            {
                RightClick.ShowAt(null, (e as RightTappedRoutedEventArgs).GetPosition(null));
            }
            else
            {
                RightClick.ShowAt(sender as FrameworkElement);
            }

            Style s = new Windows.UI.Xaml.Style {
                TargetType = typeof(MenuFlyoutPresenter)
            };

            s.Setters.Add(new Setter(RequestedThemeProperty, Config.GetBoolean(Config.DarkTheme) ? ElementTheme.Dark : ElementTheme.Light));
            RightClick.MenuFlyoutPresenterStyle = s;

            if (!IsServer)
            {
                var key = Config.PerChannelSetting(Server, Title, Config.AlwaysNotify);
                AlwaysPing.IsChecked = Config.GetBoolean(key, false);
            }
        }
コード例 #7
0
        public void ShowToast(string descripition)
        {
            var label = new TextBlock
            {
                Text                = descripition,
                Foreground          = new SolidColorBrush(Windows.UI.Colors.White),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };
            var style = new Windows.UI.Xaml.Style {
                TargetType = typeof(FlyoutPresenter)
            };

            style.Setters.Add(new Windows.UI.Xaml.Setter(Control.BackgroundProperty, new SolidColorBrush(Windows.UI.Colors.Black)));
            style.Setters.Add(new Windows.UI.Xaml.Setter(FrameworkElement.MaxHeightProperty, 1));
            var flyout = new Flyout
            {
                Content              = label,
                Placement            = FlyoutPlacementMode.Full,
                FlyoutPresenterStyle = style,
            };

            flyout.ShowAt(Window.Current.Content as FrameworkElement);

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(2)
            };

            timer.Tick += (sender, e) => {
                timer.Stop();
                flyout.Hide();
            };
            timer.Start();
        }
コード例 #8
0
        public static Style ResolveStyleFromResourceDictionary(ResourceDictionary rd, string key)
        {
            Windows.UI.Xaml.Style st = null;
            try
            {
                if (rd != null)
                {
                    if (rd.ContainsKey(key))
                    {
                        if (rd[key] is Style)
                        {
                            return((Style)rd[key]);
                        }
                    }
                }

                if (CoreThemeResourceDictionary.ContainsKey(key))
                {
                    if (CoreThemeResourceDictionary[key] is Style)
                    {
                        return((Style)CoreThemeResourceDictionary[key]);
                    }
                }
            }
            catch (Exception e)
            {
            }
            return(null);
        }
コード例 #9
0
		Style GetStyle(object nativeKey)
		{
			var style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources[nativeKey];

			var formsStyle = new Style(typeof(Label));
			foreach (SetterBase b in style.Setters)
			{
				var setter = b as Windows.UI.Xaml.Setter;
				if (setter == null)
					continue;

				// TODO: Need to implement a stealth pass-through for things we don't support

				try
				{
					if (setter.Property == TextBlock.FontSizeProperty)
						formsStyle.Setters.Add(Label.FontSizeProperty, setter.Value);
					else if (setter.Property == TextBlock.FontFamilyProperty)
						formsStyle.Setters.Add(Label.FontFamilyProperty, setter.Value);
					else if (setter.Property == TextBlock.FontWeightProperty)
						formsStyle.Setters.Add(Label.FontAttributesProperty, ToAttributes(Convert.ToUInt16(setter.Value)));
					else if (setter.Property == TextBlock.TextWrappingProperty)
						formsStyle.Setters.Add(Label.LineBreakModeProperty, ToLineBreakMode((TextWrapping)setter.Value));
				}
				catch (NotImplementedException)
				{
					// see https://bugzilla.xamarin.com/show_bug.cgi?id=33135
					// WinRT implementation of Windows.UI.Xaml.Setter.get_Value is not implemented.
				}
			}

			return formsStyle;
		}
コード例 #10
0
 private Windows.UI.Xaml.Style GetStyle()
 {
     Windows.UI.Xaml.Style s = new Windows.UI.Xaml.Style(typeof(Windows.UI.Xaml.Shapes.Path));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.StrokeProperty, new SolidColorBrush(Colors.Black)));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.StrokeThicknessProperty, 1d));
     return(s);
 }
コード例 #11
0
ファイル: AppBarToggleButton.cs プロジェクト: sdao/TuneOut
        private void IsCheckedChanged()
        {
            if (IsChecked)
            {
                if (CheckedStyle != null)
                {
                    _style = Style;
                    Style = CheckedStyle;
                }

                if (CheckedAutomationName != null)
                {
                    _automationName = AutomationName;
                    AutomationName = CheckedAutomationName;
                }
            }
            else
            {
                if (CheckedStyle != null)
                {
                    Style = _style;
                }

                if (CheckedAutomationName != null)
                {
                    AutomationName = _automationName;
                }
            }
        }
コード例 #12
0
 internal static void PrepareContainerForItemOverride(DependencyObject element, Style parentItemContainerStyle)
 {
     var control = element as Control;
     if (parentItemContainerStyle != null && control != null && control.Style == null)
     {
         control.SetValue(FrameworkElement.StyleProperty, parentItemContainerStyle);
     }
 }
コード例 #13
0
        private static Style GetButtonStyle(Color backgroundColor)
        {
            var redButtonStyle = new Windows.UI.Xaml.Style(typeof(Button));

            redButtonStyle.Setters.Add(new Setter(Control.BackgroundProperty, backgroundColor));
            redButtonStyle.Setters.Add(new Setter(Control.ForegroundProperty, Colors.White));
            return(redButtonStyle);
        }
コード例 #14
0
 public void UpdateStyle(Windows.UI.Xaml.Style style)
 {
     _style = style;
     if (!_accessibilitySettings.HighContrast)
     {
         _element.Style = style;
     }
 }
コード例 #15
0
 public ExceptHighContrastPrivateData(FrameworkElement element, Windows.UI.Xaml.Style style)
 {
     _element = element;
     _style   = style;
     _accessibilitySettings = new AccessibilitySettings();
     _accessibilitySettings.HighContrastChanged += AccessibilitySettings_HighContrastChanged;
     ComputeStyle();
 }
コード例 #16
0
 internal static void PreparePrepareHeaderedItemsControlContainerForItemOverride(DependencyObject element, object item, ItemsControl parent, Style parentItemContainerStyle)
 {
     var headeredItemsControl = element as HeaderedItemsControl;
     if (headeredItemsControl != null)
     {
         PreparePrepareHeaderedItemsControlContainer(headeredItemsControl, item, parent, parentItemContainerStyle);
     }
 }
コード例 #17
0
        public SharedBrushWithStylePage() {
            // Taken from Petzold book but never tested. Needs another setter for LinearGradientBrush.
            Style style = new Style(typeof(TextBlock));
            style.Setters.Add(new Setter { Property = TextBlock.FontSizeProperty, Value = 96 });
            style.Setters.Add(new Setter { Property = TextBlock.FontFamilyProperty, Value = "Times New Roman" });
            this.Resources.Add("rainbowStyle", style);

            this.InitializeComponent();
        }
コード例 #18
0
        public AdaptiveGridView()
        {
            if (ItemContainerStyle == null)
                ItemContainerStyle = new Style(typeof(GridViewItem));

            ItemContainerStyle.Setters.Add(new Setter(HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
            
            Loaded += AdaptiveGridView_Loaded;
        }
コード例 #19
0
        public static Grid CreateGrid(Style s, Grid g)
        {
            Grid newG = new Grid();
            newG.Style = s;

            g.Children.Add(newG);

            return newG;
        }
コード例 #20
0
 private Style GetDecoratorStyle()
 {
     Windows.UI.Xaml.Style s = new Windows.UI.Xaml.Style(typeof(Windows.UI.Xaml.Shapes.Path));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.StrokeProperty, new SolidColorBrush(Colors.Black)));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.WidthProperty, 10));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.HeightProperty, 10));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.StrokeThicknessProperty, 1d));
     s.Setters.Add(new Setter(Windows.UI.Xaml.Shapes.Path.StretchProperty, Stretch.Fill));
     return(s);
 }
コード例 #21
0
        public static TextBlock CreateTextBlock(string txt, Style s, Grid g)
        {
            TextBlock tB = new TextBlock();

            tB.Text = txt;
            tB.Style = s;
            g.Children.Add(tB);

            return tB;
        }
コード例 #22
0
        public static TextBox CreateTextBox(string name,Style s, Grid g)
        {
            TextBox tB = new TextBox();

            tB.Name = name;
            tB.Style = s;

            g.Children.Add(tB);

            return tB;
        }
コード例 #23
0
        protected override Style SelectStyleCore(object item, DependencyObject container)
        {
            SolidColorBrush highlight;
            if (_index % 2 == 0)
                highlight = new SolidColorBrush(Colors.White);
            else
                highlight = new SolidColorBrush(Colors.CornflowerBlue);

            _index++;
            Style style = new Style(container.GetType());
            style.Setters.Add(new Setter(Control.BackgroundProperty, highlight));
            return style;
        }
コード例 #24
0
 public static Button GetButton(string content, Style style, RoutedEventHandler callback, object tag = null)
 {
     Button btn = new Button();
     btn.Content = content;
     btn.Margin = new Thickness(0, 0, 0, 0);
     btn.Tag = tag;
     btn.Loaded += btn_Loaded;
     if (style != null)
         btn.Style = style;
     if (callback != null)
         btn.Click += callback;
     return btn;
 }
コード例 #25
0
        public static Button CreateButton(string name, Style s, string content, RoutedEventHandler button_Click, Grid g)
        {
            Button button = new Button();

            button.Name = name + "_Button";
            button.Style = s;
            button.Content = content;
            button.Click += button_Click;

            g.Children.Add(button);

            return button;
        }
コード例 #26
0
ファイル: Style.xaml.cs プロジェクト: webabcd/Windows10
        // 在 c# 中定义样式
        private void Style_Loaded(object sender, RoutedEventArgs e)
        {
            Windows.UI.Xaml.Style style = new Windows.UI.Xaml.Style();
            style.TargetType = typeof(TextBox);

            Setter setter1 = new Setter();

            setter1.Property = TextBox.BackgroundProperty;
            setter1.Value    = Colors.Blue;

            style.Setters.Add(setter1);

            textBox4.Style = style;
        }
コード例 #27
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);
            if (this.Control != null)
            {
                this.Control.BorderThickness   = new Windows.UI.Xaml.Thickness(0);
                this.Control.VerticalAlignment = VerticalAlignment.Center;

                // Make the text vertically aligned at centre of the entry.
                Style style = new Style(typeof(Windows.UI.Xaml.Controls.ContentControl));
                style.Setters.Add(new Setter(VerticalAlignmentProperty, VerticalAlignment.Center));
                this.Control.Resources.Add(typeof(Windows.UI.Xaml.Controls.ContentControl), style);
            }
        }
コード例 #28
0
ファイル: MainPage.xaml.cs プロジェクト: simple0812/uwp
        public MainPage()
        {
            this.InitializeComponent();

            Style style = new Style(typeof(Button));
            style.Setters.Add(new Setter(Button.HeightProperty, 70));
            style.Setters.Add(new Setter(Button.WidthProperty, 140));
            style.Setters.Add(new Setter(Button.BackgroundProperty, Colors.Orange));
            btn.Style = style;

            btn2.Style = (Style)Application.Current.Resources["btn_140x70"];

            
        }
コード例 #29
0
        protected override Style SelectStyleCore(object item, DependencyObject container)
        {
            var style = new Style {TargetType = typeof (ListViewItem)};
            var backgroudSetter = new Setter {Property = Windows.UI.Xaml.Controls.Control.BackgroundProperty};

            var listview = ItemsControl.ItemsControlFromItemContainer(container) as ListView;
            if (listview != null)
            {
                var index = listview.IndexFromContainer(container);
                backgroudSetter.Value = index%2==0 ? EvenColorBrush : OddColorBrush ;
            }
            style.Setters.Add(backgroudSetter);

            return style;
        }
コード例 #30
0
        static Windows.UI.Xaml.Style GetAncestorSetters(Windows.UI.Xaml.Style value)
        {
            var style = new Windows.UI.Xaml.Style(value.TargetType)
            {
                BasedOn = value.BasedOn
            };

            foreach (var valSetter in value.Setters)
            {
                style.Setters.Add(valSetter);
            }

            var ancestorStyles = new List <Windows.UI.Xaml.Style> ();

            Windows.UI.Xaml.Style currStyle = style;
            while (currStyle.BasedOn != null)
            {
                ancestorStyles.Add(currStyle.BasedOn);
                currStyle = currStyle.BasedOn;
            }

            foreach (var styleParent in ancestorStyles)
            {
                foreach (var b in styleParent.Setters)
                {
                    var parentSetter = b as Windows.UI.Xaml.Setter;
                    if (parentSetter == null)
                    {
                        continue;
                    }

                    var derviedSetter = style.Setters
                                        .OfType <Windows.UI.Xaml.Setter> ()
                                        .FirstOrDefault(x => x.Property == parentSetter.Property);

                    //Ignore any ancestor setters which a child setter has already overridden
                    if (derviedSetter != null)
                    {
                        continue;
                    }
                    else
                    {
                        style.Setters.Add(parentSetter);
                    }
                }
            }
            return(style);
        }
コード例 #31
0
ファイル: TreeViewHandler.cs プロジェクト: daddycoding/Eto
        public TreeViewHandler()
        {
            Control = new EtoTreeView {
                Handler = this
            };
            SetTemplate();

#if TODO_XAML
            var style = new sw.Style(typeof(mwc.TreeViewItem));
            //style.Setters.Add (new sw.Setter (mwc.TreeViewItem.IsExpandedProperty, new swd.Binding { Converter = new WpfTreeItemHelper.IsExpandedConverter (), Mode = swd.BindingMode.OneWay }));
            style.Setters.Add(new sw.Setter(mwc.TreeViewItem.IsExpandedProperty, new swd.Binding {
                Path = expandedProperty, Mode = swd.BindingMode.OneTime
            }));
            Control.ItemContainerStyle = style;
#endif
        }
コード例 #32
0
        private void IsCheckedChanged()
        {
            if (IsChecked)
            {
                _content = Content;
                _style = Style;

                if (CheckedStyle == null) Content = CheckedContent;
                else Style = CheckedStyle;
            }
            else
            {
                if (CheckedStyle == null) Content = _content;
                else Style = _style;
            }
        }
コード例 #33
0
ファイル: UsersView.xaml.cs プロジェクト: owensdj/WinIRC
        private void ShowContextMenu(UIElement target, Point offset)
        {
            var RightClick = this.Resources["UserContextMenu"] as MenuFlyout;

            System.Diagnostics.Debug.WriteLine("MenuFlyout shown '{0}', '{1}'", target, offset);

            RightClick.ShowAt(target, offset);

            Style s = new Windows.UI.Xaml.Style {
                TargetType = typeof(MenuFlyoutPresenter)
            };

            s.Setters.Add(new Setter(RequestedThemeProperty, Config.GetBoolean(Config.DarkTheme) ? ElementTheme.Dark : ElementTheme.Light));
            RightClick.MenuFlyoutPresenterStyle = s;

            UsernameItem.Text = UserSelected;
        }
コード例 #34
0
        private void AccountsFlyout_Opened(object sender, object e)
        {
            Flyout f = sender as Flyout;
            Style  s = new Windows.UI.Xaml.Style {
                TargetType = typeof(FlyoutPresenter)
            };

            s.Setters.Add(new Setter(MinHeightProperty, "200"));
            s.Setters.Add(new Setter(MinWidthProperty, (Width - 20).ToString()));
            f.FlyoutPresenterStyle = s;

            foreach (var a in App.AccountManager.MojangAccounts)
            {
                a.IsSelected = a == Furnace.Settings.AppSettings.SelectedAccount;
            }
            AccountsItemsControl.ItemsSource = App.AccountManager.MojangAccounts;
        }
コード例 #35
0
 protected bool CreateControl()
 {
     if (Control == null)
     {
         if (Element != null)
         {
             var control = new TNativeElement();
             defaultStyle = control.Style;
             SetNativeControl(control);
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #36
0
        private void V_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("Melodies"))
            {
                PivotItem pi = new PivotItem();
                pi.Header = "songs";

                StrechItemsListView lv = new StrechItemsListView();
                Style s = new Style(typeof(ListViewItem));
                s.Setters.Add(new Setter(ListViewItem.HorizontalContentAlignmentProperty, HorizontalAlignment.Stretch));
                lv.ItemContainerStyle = s;
                lv.ItemsSource = ((WeaponDetailsViewModel)DataContext).Melodies;
                lv.ItemTemplate = Resources["SongTemplate"] as DataTemplate;
                pi.Content = lv;
                pivot.Items.Insert(1, pi);
            }
        }
コード例 #37
0
 /// <summary>
 /// Acquires a dependent axis suitable for use with the data values of the series.
 /// </summary>
 /// <returns>Axis instance.</returns>
 protected override IAxis AcquireDependentAxis()
 {
     IAxis dependentAxis = SeriesHost.Axes
         .Where(a => (a.Orientation == DependentAxisOrientation) && (a is IRangeAxis) && DataItems.Any() && (a.CanPlot(DataItems.First().ActualDependentValue)))
         .FirstOrDefault();
     if (null == dependentAxis)
     {
         LinearAxis linearAxis = new LinearAxis { Orientation = DependentAxisOrientation, ShowGridLines = true };
         if (IsStacked100)
         {
             Windows.UI.Xaml.Style style = new Style(typeof(AxisLabel));
             style.Setters.Add(new Setter(AxisLabel.StringFormatProperty, "{0}%"));
             linearAxis.AxisLabelStyle = style;
         }
         dependentAxis = linearAxis;
     }
     return dependentAxis;
 }
コード例 #38
0
ファイル: Utility.cs プロジェクト: bdecori/win8
        protected override Style SelectStyleCore(object item, DependencyObject container)
        {
            Style style = new Style(typeof(ListViewItem));

            ChartSectionItem csi = item as ChartSectionItem;

            if (csi.highlight.Contains("red") || csi.exphighlight.Contains("red"))
            {
                style.Setters.Add(new Setter(ListViewItem.ForegroundProperty, new SolidColorBrush(Colors.Red)));
            }
            else
            {
                style.Setters.Add(new Setter(ListViewItem.ForegroundProperty, new SolidColorBrush(Colors.Black)));
            }
           
            
            return style;
        }
コード例 #39
0
ファイル: SaleStats.xaml.cs プロジェクト: XF9/EVE-Sales
        async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            activeCharacter = e.Parameter as Character;

            // load all transaction items
            var sqlite = new SQLiteAsyncConnection(activeCharacter.CharID + ".sqlite");

            List<Transaction> items = await sqlite.QueryAsync<Transaction>("SELECT * FROM 'Transaction' GROUP BY TypeID ORDER BY TypeName");
            this.Itemlist.ItemsSource = items;
            this.Categories.AddItems(items);
            this.Categories.ItemSelect += this.LoadData;

            SolidColorBrush line_sales = new SolidColorBrush(Color.FromArgb(255, 116, 195, 101));
            Style point_sales = new Style();
            point_sales.TargetType = typeof(DataPoint);
            point_sales.Setters.Add(new Setter(BackgroundProperty, line_sales));
            (LineChart.Series[0] as LineSeries).Background = line_sales;
            (LineChart.Series[0] as LineSeries).DataPointStyle = point_sales;

            SolidColorBrush line_salesAvg = new SolidColorBrush(Color.FromArgb(255, 34, 139, 34));
            Style point_salesAvg = new Style();
            point_salesAvg.TargetType = typeof(DataPoint);
            point_salesAvg.Setters.Add(new Setter(BackgroundProperty, line_salesAvg));
            point_salesAvg.Setters.Add(new Setter(WidthProperty, 0));
            point_salesAvg.Setters.Add(new Setter(HeightProperty, 0));
            (LineChart.Series[1] as LineSeries).Background = line_salesAvg;
            (LineChart.Series[1] as LineSeries).DataPointStyle = point_salesAvg;

            SolidColorBrush line_buys = new SolidColorBrush(Color.FromArgb(255, 196, 2, 51));
            Style point_buys = new Style();
            point_buys.TargetType = typeof(DataPoint);
            point_buys.Setters.Add(new Setter(BackgroundProperty, line_buys));
            (LineChart.Series[2] as LineSeries).Background = line_buys;
            (LineChart.Series[2] as LineSeries).DataPointStyle = point_buys;

            SolidColorBrush line_buysAvg = new SolidColorBrush(Color.FromArgb(255, 237, 28, 36));
            Style point_buysAvg = new Style();
            point_buysAvg.TargetType = typeof(DataPoint);
            point_buysAvg.Setters.Add(new Setter(BackgroundProperty, line_buysAvg));
            point_buysAvg.Setters.Add(new Setter(WidthProperty, 0));
            point_buysAvg.Setters.Add(new Setter(HeightProperty, 0));
            (LineChart.Series[3] as LineSeries).Background = line_buysAvg;
            (LineChart.Series[3] as LineSeries).DataPointStyle = point_buysAvg;
        }
コード例 #40
0
        public async Task ShowDialog()
        {
            Style s = new Windows.UI.Xaml.Style {
                TargetType = typeof(FlyoutPresenter)
            };

            s.Setters.Add(new Setter(FlyoutPresenter.MinWidthProperty, 1600));
            cd.FlyoutPresenterStyle = s;
            cd.Placement            = FlyoutPlacementMode.Top;

            Grid g = ((Grid) new Grid());

            InitalizeUSKeyboard(g);
            g.HorizontalAlignment = HorizontalAlignment.Stretch;

            cd.Content = g;
            cd.ShowAt((FrameworkElement)this);
            RefreshKeyboard();
        }
コード例 #41
0
        public DangerDayCellStyle(string color, int thickness) {
            cellStyle = new CalendarCellStyle();
            Style blackOutDecoration = new Style(typeof(Border));
            Style blackOutContent = new Style(typeof(TextBlock));

            char[] delimiter = { ',' };
            byte[] rgbColor = color.Split(delimiter).Select(e=> Byte.Parse(e)).ToArray();
            Color red = Color.FromArgb(255, rgbColor[0], rgbColor[1], rgbColor[2]);

            blackOutDecoration.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(red)));
            blackOutDecoration.Setters.Add(new Setter(Border.CornerRadiusProperty, new CornerRadius(60)));
            blackOutDecoration.Setters.Add(new Setter(Border.BorderThicknessProperty, new Thickness(thickness)));
            cellStyle.DecorationStyle = blackOutDecoration;

            blackOutContent.Setters.Add(new Setter(TextBlock.FontSizeProperty, 35));
            blackOutContent.Setters.Add(new Setter(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center));
            blackOutContent.Setters.Add(new Setter(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center));
            cellStyle.ContentStyle = blackOutContent;
        }
コード例 #42
0
ファイル: EditableTextBlock.cs プロジェクト: mhusen/Eto
		public EditableTextBlock()
		{
			var textBox = new FrameworkElementFactory(typeof(TextBox));
			textBox.SetValue(Control.PaddingProperty, new Thickness(1)); // 1px for border
			textBox.AddHandler(FrameworkElement.LoadedEvent, new RoutedEventHandler(TextBox_Loaded));
			textBox.AddHandler(UIElement.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
			textBox.AddHandler(UIElement.LostFocusEvent, new RoutedEventHandler(TextBox_LostFocus));
			textBox.SetBinding(TextBox.TextProperty, new Windows.UI.Xaml.Data.Binding("Text") { Source = this, Mode = BindingMode.TwoWay
#if TODO_XAML
				, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged 
#endif
			});
			var editTemplate = new DataTemplate { VisualTree = textBox };

			var textBlock = new FrameworkElementFactory(typeof(TextBlock));
			textBlock.SetValue(FrameworkElement.MarginProperty, new Thickness(2));
			textBlock.AddHandler(UIElement.PointerPressedEvent, (s, e) => {
				PointerPoint pt;
				if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse &&
					(pt = e.GetCurrentPoint(textBlock) != null) &&
#if TODO_XAML
					e.ClickCount >= 2 &&
#endif
					pt.Properties.IsLeftButtonPressed)
				{
					IsInEditMode = true;
					e.Handled = true;
				}

			});
			textBlock.SetBinding(TextBlock.TextProperty, new Windows.UI.Xaml.Data.Binding("Text") { Source = this });
			var viewTemplate = new DataTemplate { VisualTree = textBlock };

			var style = new Windows.UI.Xaml.Style(typeof(EditableTextBlock));
			var trigger = new Trigger { Property = IsInEditModeProperty, Value = true };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = editTemplate });
			style.Triggers.Add(trigger);

			trigger = new Trigger { Property = IsInEditModeProperty, Value = false };
			trigger.Setters.Add(new Setter { Property = ContentTemplateProperty, Value = viewTemplate });
			style.Triggers.Add(trigger);
			Style = style;
		}
        protected override Style SelectStyleCore(object item, DependencyObject container)
        {
            Style st = new Style();
            st.TargetType = typeof(ListViewItem);
            Setter backGroundSetter = new Setter();
            backGroundSetter.Property = ListViewItem.BackgroundProperty;
            ListView listView = ItemsControl.ItemsControlFromItemContainer(container) as ListView;
            int index = listView.IndexFromContainer(container);

            if (index % 2 == 0)
            {
                backGroundSetter.Value = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
            }
            else
            {
                backGroundSetter.Value = new SolidColorBrush(Color.FromArgb(75,255,255,255));
            }
            st.Setters.Add(backGroundSetter);
            return st;
        }
コード例 #44
0
 internal void UpdateItemContainerStyle(Style itemContainerStyle)
 {
     if (itemContainerStyle == null)
     {
         return;
     }
     var itemsHost = ItemHost;
     if (itemsHost == null || itemsHost.Children == null)
     {
         return;
     }
     foreach (var element in itemsHost.Children)
     {
         var obj = element as FrameworkElement;
         if (obj != null && obj.Style == null)
         {
             obj.Style = itemContainerStyle;
         }
     }
 }
コード例 #45
0
        private void ShowMessage(string message, double duration)
        {
            FlyoutPlacementMode position = FlyoutPlacementMode.Bottom;

            var label = new TextBlock
            {
                Text                = message,
                Foreground          = new SolidColorBrush(Windows.UI.Colors.White),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Center,
            };
            var style = new Windows.UI.Xaml.Style {
                TargetType = typeof(FlyoutPresenter)
            };

            style.Setters.Add(new Windows.UI.Xaml.Setter(Control.BackgroundProperty, new SolidColorBrush(Windows.UI.Colors.Gray)));
            style.Setters.Add(new Windows.UI.Xaml.Setter(FrameworkElement.MaxHeightProperty, 1));
            var flyout = new Flyout
            {
                Content = label,
                AllowFocusOnInteraction = false,
                Placement            = position,
                FlyoutPresenterStyle = style,
            };

            flyout.OverlayInputPassThroughElement = Window.Current.Content;
            FrameworkElement mainElement = Window.Current.Content as FrameworkElement;

            flyout.ShowAt(mainElement);

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(duration)
            };

            timer.Tick += (sender, e) => {
                timer.Stop();
                flyout.Hide();
            };
            timer.Start();
        }
コード例 #46
0
		private void buildColumn(int dayOfWeek)
		{
			int row = 0;
			var end = new DateTime(1, 1, 2, 0, 0, 0);
			for (DateTime dt = new DateTime(1, 1, 1, 0, 0, 0); dt < end; dt = dt.AddMinutes(30))
			{
				Border b = new Border();
				b.SetValue(Grid.ColumnProperty, dayOfWeek);
				b.SetValue(Grid.RowProperty, row);
				b.Tag = new BorderTag()
				{
					DayOfWeek = dayOfWeek,
					CellDateTime = dt
				};
				b.Tapped += Border_Tapped;

				if (dt.Minute == 0)
				{
					b.Style = tempHourStart ?? (tempHourStart = this.TryFindResource("TempHourStart") as Style);
					b.HorizontalAlignment = HorizontalAlignment.Stretch;
					b.VerticalAlignment = VerticalAlignment.Stretch;

					TextBlock tb = new TextBlock();
					b.Child = tb;
					tb.Text = dt.ToString("h t").ToLower();
				}
				else
				{
					b.Style = tempHourEnd ?? (tempHourEnd = this.TryFindResource("TempHourEnd") as Style);
					b.HorizontalAlignment = HorizontalAlignment.Stretch;
					b.VerticalAlignment = VerticalAlignment.Stretch;

				}
				Calander.Children.Add(b);

				row++;
			}
		}
コード例 #47
0
        public PlayerArea(Player player, Grid grid, Style gridStyle ,ResourceDictionary Resources)
        {
            string dealer = "";

            RoutedEventHandler rehOneMore = new RoutedEventHandler(Life_One_More_Click);
            RoutedEventHandler rehFiveMore = new RoutedEventHandler(Life_Five_More_Click);
            RoutedEventHandler rehOneLess = new RoutedEventHandler(Life_One_Less_Click);

            this._player = player;
            this._grid = grid;

            if (_player.Dealer == true)
                dealer = "D";

            _areaGrid = CreateXAMLObj.CreateGrid(gridStyle, _grid);
            _playerTextBlock = CreateXAMLObj.CreateTextBlock(_player.Name, Resources["TextBlockPlayerNameStyle"] as Style, _areaGrid);
            _winTextBlock = CreateXAMLObj.CreateTextBlock(_player.Wins.ToString() + " W", Resources["TextBlockWinStyle"] as Style, _areaGrid);
            _dealerTextBlock = CreateXAMLObj.CreateTextBlock(dealer, Resources["TextBlockDealerStyle"] as Style, _areaGrid);

            _lifeButton = CreateXAMLObj.CreateButton("Life", Resources["ButtonLifeStyle"] as Style, _player.Life.ToString(), rehOneLess, _areaGrid);
            _addOneLifeButton = CreateXAMLObj.CreateButton("Add_One_Life", Resources["ButtonAddOneLifeStyle"] as Style, "+1", rehOneMore, _areaGrid);
            _addFiveLifeButton = CreateXAMLObj.CreateButton("Add_Five_Life", Resources["ButtonAddFiveLifeStyle"] as Style, "+5", rehFiveMore, _areaGrid);
        }
コード例 #48
0
ファイル: InputComboBoxItem.cs プロジェクト: liquidboy/X
        protected override void OnApplyTemplate()
        {
            if (_model == null)
            {
                _model = new InputModel();
            }

            if (_grdRoot == null)
            {
                _grdRoot = GetTemplateChild("grdRoot") as Grid;
                _grdRoot.DataContext = _model;
            }

            if (_GeneralComboBoxItemStyle == null)
            {
                _GeneralComboBoxItemStyle = (Style)_grdRoot.Resources["GeneralComboBoxItemStyle"];
            }

            this.Style = _GeneralComboBoxItemStyle;


            base.OnApplyTemplate();
        }
コード例 #49
0
        private async void disableAccBtn_Click(object sender, RoutedEventArgs e)
        {
            var contentDialog = new ContentDialog();

            contentDialog.Title               = "Disable user?";
            contentDialog.Content             = "Are you sure to disable this account? The user won't be able to login to the system. This won't disable student account in AD, and account enabled status won't be synced.";
            contentDialog.PrimaryButtonText   = "Disable";
            contentDialog.SecondaryButtonText = "Cancel";

            var bst = new Windows.UI.Xaml.Style(typeof(Button));

            bst.Setters.Add(new Setter(Button.BackgroundProperty, Colors.DarkRed));
            bst.Setters.Add(new Setter(Button.ForegroundProperty, Colors.White));
            contentDialog.PrimaryButtonStyle = bst;

            ContentDialogResult result = await contentDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                loadGrid.Visibility = Visibility.Visible;
                progText.Text       = "Making changes...";
                user.isDisabled     = true;
                await SettingsHelper.Instance.op2.UpdateUser(user);

                progText.Text = "Just a moment...";
                var newUser = await SettingsHelper.Instance.op2.GetUserById(user.userID);

                while (newUser == null)
                {
                }

                user = newUser;

                LoadUserInfo();
                loadGrid.Visibility = Visibility.Collapsed;
            }
        }
コード例 #50
0
ファイル: Rating.cs プロジェクト: WillemGijsbers/callisto
 /// <summary>
 /// ItemContainerStyleProperty property changed handler.
 /// </summary>
 /// <param name="newValue">New value.</param>        
 protected virtual void OnItemContainerStyleChanged(Style newValue)
 {
     ItemsControlHelper.UpdateItemContainerStyle(newValue);
 }
コード例 #51
0
 public static void SetExceptHighContrast(DependencyObject sender, Windows.UI.Xaml.Style value)
 {
     sender?.SetValue(ExceptHighContrastProperty, value);
 }
コード例 #52
0
 protected void InitializeDocumentContainer(FrameworkElement documentContainer, DependencyProperty documentContainerViewProperty, Style documentContainerStyle)
 {
     ViewHelper.SetBindingToViewModel(documentContainer, FrameworkElement.DataContextProperty, new PropertyPath(documentContainerViewProperty));
     if (documentContainerStyle != null)
     {
         documentContainer.Style = documentContainerStyle;
     }
 }
コード例 #53
0
ファイル: SplitterHandler.cs プロジェクト: nzysoft/Eto
        public SplitterHandler()
        {
            Control = new swc.Grid();
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition());
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition {
                Width = sw.GridLength.Auto
            });
            Control.ColumnDefinitions.Add(new swc.ColumnDefinition());
            Control.RowDefinitions.Add(new swc.RowDefinition());
            Control.RowDefinitions.Add(new swc.RowDefinition {
                Height = sw.GridLength.Auto
            });
            Control.RowDefinitions.Add(new swc.RowDefinition());

            splitter = new swc.GridSplitter
            {
                //Background = sw.SystemColors.ControlLightLightBrush,
                ResizeBehavior = swc.GridResizeBehavior.PreviousAndNext
            };
            pane1 = new swc.DockPanel {
                LastChildFill = true
            };
            pane2 = new swc.DockPanel {
                LastChildFill = true
            };


            Control.Children.Add(pane1);
            Control.Children.Add(splitter);
            Control.Children.Add(pane2);

            style = new sw.Style();
            style.Setters.Add(new sw.Setter(sw.FrameworkElement.VerticalAlignmentProperty, sw.VerticalAlignment.Stretch));
            style.Setters.Add(new sw.Setter(sw.FrameworkElement.HorizontalAlignmentProperty, sw.HorizontalAlignment.Stretch));

            UpdateOrientation();
            Control.Loaded += delegate
            {
                // controls should be stretched to fit panels
                SetStretch(panel1);
                SetStretch(panel2);
                UpdateColumnSizing();
                if (FixedPanel == SplitterFixedPanel.Panel2)
                {
                    var size = panel2.GetPreferredSize(Conversions.PositiveInfinitySize);
                    var currentOrientation = Orientation;
                    if (currentOrientation == SplitterOrientation.Horizontal)
                    {
                        var width = (int)Control.ActualWidth;
                        position = position ?? (int)(width - size.Width);
                        Position = Size.Width - (width - position.Value);
                    }
                    else if (currentOrientation == SplitterOrientation.Vertical)
                    {
                        var height = (int)Control.ActualHeight;
                        position = position ?? (int)(height - size.Height);

                        Position = Size.Height - (height - position.Value);
                    }
                    else if (position != null)
                    {
                        Position = position.Value;
                    }
                }
                else if (position != null)
                {
                    Position = position.Value;
                }
            };
        }
コード例 #54
0
 protected Style GetDocumentContainerStyle(DependencyObject documentContainer, object view, Style style, StyleSelector styleSelector)
 {
     return(style ?? styleSelector.With(s => s.SelectStyle(ViewHelper.GetViewModelFromView(view), documentContainer)));
 }