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


C# ResourceDictionary.Add方法代码示例

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


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

示例1: MyPage

        public MyPage()
        {
            Resources = new ResourceDictionary();
            Resources.Add("primaryGreen", Color.FromHex("91CA47"));
            Resources.Add("primaryDarkGreen", Color.FromHex("6FA22E"));

            var nav = new NavigationPage(new AAloggerUpSwipeView());
            nav.BarTextColor = Color.Blue;

            MainPage = nav;
        }
开发者ID:Raja413,项目名称:Logger,代码行数:11,代码来源:MyPage.cs

示例2: App

        public App()
        {
            #region Style
            var contentPageStyle = new Style(typeof(ContentPage))
            {
                Setters = {
                new Setter { Property = ContentPage.BackgroundColorProperty, Value = Constants.palette.primary },
                }
            };
            var labelStyle = new Style(typeof(Label))
            {
                Setters = {
                new Setter { Property = Label.TextColorProperty, Value = Constants.palette.primary_text },
                }
            };
            var editorStyle = new Style(typeof(Editor))
            {
                Setters = {
                new Setter { Property = Editor.TextColorProperty, Value = Constants.palette.primary_text },
                new Setter { Property = Editor.BackgroundColorProperty, Value = Constants.palette.primary_light },
                }
            };
            var buttonStyle = new Style(typeof(Button))
            {
                Setters = {
                new Setter { Property = Button.TextColorProperty, Value = Constants.palette.primary_text },
                new Setter { Property = Button.BackgroundColorProperty, Value = Constants.palette.primary_light },
                }
            };
            var switchStyle = new Style(typeof(Switch))
            {
                Setters = {
                new Setter { Property = Switch.BackgroundColorProperty, Value = Constants.palette.primary_light },
                }
            };

            Resources = new ResourceDictionary();
            Resources.Add("contentPageStyle", contentPageStyle);
            Resources.Add("labelStyle", labelStyle);
            Resources.Add("editorStyle", editorStyle);

            #endregion

            // The root page of your application
            mainPage = new NavigationPage(new mainPage())
            {
                BarBackgroundColor = Constants.palette.primary_dark,
                BarTextColor = Constants.palette.icons,
                Title = "VOCAB MASTER",

            };
            MainPage = mainPage;
        }
开发者ID:Riley19280,项目名称:Vocab-Master-App,代码行数:53,代码来源:App.cs

示例3: App

		public App ()
		{
			Resources = new ResourceDictionary ();
			Resources.Add ("primaryGreen", Color.FromHex("91CA47"));
			Resources.Add ("primaryDarkGreen", Color.FromHex ("6FA22E"));

			var nav = new NavigationPage (new TodoListPage ());
			nav.BarBackgroundColor = (Color)App.Current.Resources["primaryGreen"];
			nav.BarTextColor = Color.White;

			MainPage = nav;
		}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:12,代码来源:App.cs

示例4: SimpleTriggerPage

		public SimpleTriggerPage ()
		{
			var t = new Trigger (typeof(Entry));
			t.Property = Entry.IsFocusedProperty;
			t.Value = true;
			t.Setters.Add (new Setter {Property = Entry.ScaleProperty, Value = 1.5 } );


			var s = new Style (typeof(Entry));
			s.Setters.Add (new Setter { Property = AnchorXProperty, Value = 0} );
			s.Triggers.Add (t);

			Resources = new ResourceDictionary ();
			Resources.Add (s);


			Padding = new Thickness (20, 50, 120, 0);
			Content = new StackLayout { 
				Spacing = 20,
				Children = {
					new Entry { Placeholder = "enter name" },
					new Entry { Placeholder = "enter address" },
					new Entry { Placeholder = "enter city and name" },
				}
			};
		}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:26,代码来源:SimpleTriggerPage.cs

示例5: CustomEasingSwellPage

        public CustomEasingSwellPage()
        {
            Resources = new ResourceDictionary();

            Resources.Add("customEase", new Easing(t => -6 * t * t + 7 * t));

            InitializeComponent();
        }
开发者ID:xia101,项目名称:xamarin-forms-book-samples,代码行数:8,代码来源:CustomEasingSwellPage.xaml.cs

示例6: ShallowCopy

 /// <summary>
 /// Makes a shallow copy of the specified ResourceDictionary.
 /// </summary>
 /// <param name="dictionary">ResourceDictionary to copy.</param>
 /// <returns>Copied ResourceDictionary.</returns>
 public static ResourceDictionary ShallowCopy(this ResourceDictionary dictionary)
 {
     ResourceDictionary clone = new ResourceDictionary();
     foreach (object key in dictionary.Keys)
     {
         clone.Add(key, dictionary[key]);
     }
     return clone;
 }
开发者ID:jira-sarec,项目名称:ICSE-2012-TraceLab,代码行数:14,代码来源:ResourceDictionaryExtensions.cs

示例7: App

        public App()
        {
            // The root page of your application
            MainPage = new NavigationPage(new Inicio());

            // Amostra grátis de Styles
            var btnStyle = new Style(typeof(Button));
            btnStyle.Setters.Add(new Setter() { Property = Button.BackgroundColorProperty, Value = Color.Red });
            btnStyle.Setters.Add(new Setter() { Property = Button.TextColorProperty, Value = Color.White });

            Resources = new ResourceDictionary();

            Resources.Add(btnStyle);
        }
开发者ID:viniciusoreis,项目名称:Xamarin02,代码行数:14,代码来源:App.cs

示例8: ImplicitStylesPageCS

		public ImplicitStylesPageCS ()
		{
			var entryStyle = new Style (typeof(Entry)) {
				Setters = {
					new Setter { 
						Property = View.HorizontalOptionsProperty,
						Value = LayoutOptions.Fill
					},
					new Setter {
						Property = View.VerticalOptionsProperty,
						Value = LayoutOptions.CenterAndExpand
					},
					new Setter {
						Property = VisualElement.BackgroundColorProperty,
						Value = Color.Yellow
					},
					new Setter {
						Property = Entry.FontAttributesProperty,
						Value = FontAttributes.Italic
					},
					new Setter {
						Property = Entry.TextColorProperty,
						Value = Color.Blue
					} 
				}	
			};

			Title = "Implicit";
			Icon = "csharp.png";
			Padding = new Thickness (0, 20, 0, 0);
			Resources = new ResourceDictionary ();
			Resources.Add (entryStyle);

			Content = new StackLayout { 
				Children = {
					new Entry { Text = "These entries" },
					new Entry { Text = "are demonstrating" },
					new Entry { Text = "implicit styles," },
					new Entry { Text = "and an implicit style override", BackgroundColor = Color.Lime, TextColor = Color.Red },
					new CustomEntry  { Text = "Subclassed Entry is not receiving the style" }
				}
			};
		}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:43,代码来源:ImplicitStylesPageCS.cs

示例9: Clone

        private static void Clone(ResourceDictionary source, ResourceDictionary target)
        {
            foreach (var resourceKeyValue in source)
            {
                target.Add(resourceKeyValue.Key, resourceKeyValue.Value);
            }

            foreach (var dictionary in source.MergedDictionaries)
            {
                var clone = new ResourceDictionary();
                Clone(dictionary, clone);
                target.MergedDictionaries.Add(clone);
            }

            foreach (var dictionaryKeyValue in source.ThemeDictionaries)
            {
                var clone = new ResourceDictionary();
                Clone((ResourceDictionary)dictionaryKeyValue.Value, clone);
                target.ThemeDictionaries.Add(dictionaryKeyValue.Key, clone);
            }
        }
开发者ID:xyzzer,项目名称:WinRTXamlToolkit,代码行数:21,代码来源:VisualTreeViewModel.cs

示例10: RenameResources

		public void RenameResources() {
			if (resourceManagerType == null && componentResourceManagerType == null)
				return;

			var rsrcDict = new ResourceDictionary();
			foreach (var resource in module.Resources)
				rsrcDict.Add(resource);

			if (module.Assembly != null)
				Rename(rsrcDict, "", module.Assembly.Name + ".g");

			foreach (var type in callsResourceManager.Keys)
				Rename(rsrcDict, type);

			if (rsrcDict.Count != 0) {
				foreach (var type in module.GetTypes()) {
					if (rsrcDict.Count == 0)
						break;
					if (!IsWinFormType(type))
						continue;
					Rename(rsrcDict, type);
				}
			}

			if (rsrcDict.Count != 0) {
				foreach (var type in module.GetTypes()) {
					if (rsrcDict.Count == 0)
						break;
					Rename(rsrcDict, type);
				}
			}

			if (rsrcDict.Count != 0)
				Logger.e("Couldn't restore all renamed resource names");
		}
开发者ID:ximing-kooboo,项目名称:de4dot,代码行数:35,代码来源:ResourceNamesRestorer.cs

示例11: SetStyles

		private void SetStyles()
		{
			Resources = new ResourceDictionary ();

			var contentStyle = new Style (typeof(ContentPage)) {
				Setters = {
					new Setter {
						Property = ContentPage.BackgroundColorProperty,
						Value = Color.White
					}
				}
			};
			Resources.Add (contentStyle);

			var entryStyle = new Style (typeof(Entry)) {
				Setters = {
					new Setter {
						Property = Entry.BackgroundColorProperty,
						Value = Color.FromHex("EEEEEE")
					},
					new Setter {
						Property = Entry.TextColorProperty,
						Value = Color.FromHex("333333")
					},
					new Setter {
						Property = Entry.HorizontalOptionsProperty,
						Value = LayoutOptions.FillAndExpand
					},
					new Setter {
						Property = Entry.VerticalOptionsProperty,
						Value = LayoutOptions.CenterAndExpand
					}
				}
			};
			Resources.Add (entryStyle);

			var editorStyle = new Style (typeof(Editor)) {
				Setters = {
					new Setter {
						Property = Editor.BackgroundColorProperty,
						Value = Color.FromHex("EEEEEE")
					},
					new Setter {
						Property = Editor.TextColorProperty,
						Value = Color.FromHex("333333")
					},
					new Setter {
						Property = Editor.HorizontalOptionsProperty,
						Value = LayoutOptions.FillAndExpand
					},
					new Setter {
						Property = Editor.VerticalOptionsProperty,
						Value = LayoutOptions.FillAndExpand
					}
				}
			};
			Resources.Add (editorStyle);

			var pickerStyle = new Style (typeof(Picker)) {
				Setters = {
					new Setter {
						Property = Picker.BackgroundColorProperty,
						Value = Color.FromHex("EEEEEE")
					},
					new Setter {
						Property = Picker.HorizontalOptionsProperty,
						Value = LayoutOptions.FillAndExpand
					},
					new Setter {
						Property = Picker.VerticalOptionsProperty,
						Value = LayoutOptions.CenterAndExpand
					}
				}
			};
			Resources.Add (pickerStyle);

			var datePickerStyle = new Style (typeof(DatePicker)) {
				Setters = {
					new Setter {
						Property = DatePicker.BackgroundColorProperty,
						Value = Color.FromHex("EEEEEE")
					},
					new Setter {
						Property = DatePicker.HorizontalOptionsProperty,
						Value = LayoutOptions.FillAndExpand
					},
					new Setter {
						Property = DatePicker.VerticalOptionsProperty,
						Value = LayoutOptions.CenterAndExpand
					}
				}
			};
			Resources.Add (datePickerStyle);

			var buttonStyle = new Style (typeof(Button)) {
				Setters = {
					new Setter { 
						Property = Button.BackgroundColorProperty, 
						Value = Color.FromHex("DDDDDD")
					},
//.........这里部分代码省略.........
开发者ID:marciopmm,项目名称:CNE,代码行数:101,代码来源:CNE.cs

示例12: InitGlobalStyles

        private void InitGlobalStyles()
        {
            Resources = new ResourceDictionary();

            var masterDetailstyle = new Style(typeof(MasterDetailPage))
            {

                Setters =
                {
                    new Setter { Property = MasterDetailPage.BackgroundColorProperty, Value = Color.White },
                    new Setter { Property = MasterDetailPage.BackgroundColorProperty, Value = Color.White }

                }
            };
            Resources.Add(masterDetailstyle);
            //button
            var buttonStyle = new Style(typeof(Button))
            {
                Setters =
                {
                    new Setter {Property = Button.TextColorProperty, Value = Color.White},
                                        new Setter {Property = Button.BackgroundColorProperty, Value = Color.FromRgb(254,39,61)}

                }
            };
            Resources.Add(buttonStyle);

            //nav page - can't superclass
            var navPageStyle = new Style(typeof(NavigationPage))
            {
                Setters =
                {
                    new Setter {Property = NavigationPage.BackButtonTitleProperty, Value = Color.Black},
                    new Setter {Property = NavigationPage.BarTextColorProperty, Value = Color.FromRgb(254,39,61)},
                    new Setter {Property = NavigationPage.TitleProperty, Value = Color.Black},
                       new Setter {Property = NavigationPage.TitleProperty, Value = TextAlignment.End},
                    new Setter {Property = NavigationPage.BackgroundColorProperty, Value = Color.White}
                }
            };
            Resources.Add(navPageStyle);
            //Base64EncodedContent page
            var contentPageSTyle = new Style(typeof(ContentPage))
            {
                Setters =
                {
                    new Setter {Property = ContentPage.BackgroundColorProperty, Value = Color.White},
                       new Setter {Property = ContentPage.TitleProperty, Value = Color.Black}


                }
            };
            Resources.Add(contentPageSTyle);


            var labelStyle = new Style(typeof(Label))
            {
                Setters =
                {
                    new Setter {Property = Label.BackgroundColorProperty, Value = Color.White},
                    new Setter {Property = Label.TextColorProperty, Value = Color.Black},
                     new Setter {Property = Label.FontSizeProperty, Value = Font.SystemFontOfSize(NamedSize.Medium)}
                }
            };
            Resources.Add(labelStyle);


            var extendedLabelStyle = new Style(typeof(ExtendedLabel))
            {
                Setters =
                {
                    new Setter {Property = ExtendedLabel.BackgroundColorProperty, Value = Color.White},
                    new Setter {Property = ExtendedLabel.TextColorProperty, Value = Color.Black},
                     new Setter {Property = ExtendedLabel.FontSizeProperty, Value = Font.SystemFontOfSize(NamedSize.Medium)},
                     new Setter {Property = ExtendedLabel.IsUnderlineProperty, Value = true},


                }
            };
            Resources.Add(extendedLabelStyle);

            var entryStyle = new Style(typeof(Entry))
            {
                Setters =
                {
                    new Setter {Property = Entry.BackgroundColorProperty, Value = Color.White},
                    new Setter {Property = Entry.TextColorProperty, Value = Color.Black},
                      new Setter {Property = Entry.OpacityProperty, Value = 0.5}
                }
            };
            Resources.Add(entryStyle);

            var extendedEntry = new Style(typeof(ExtendedEntry))
            {
                Setters =
                {
                    new Setter {Property = ExtendedEntry.BackgroundColorProperty, Value = Color.White},
                    new Setter {Property = ExtendedEntry.TextColorProperty, Value = Color.Black},
                      new Setter {Property = ExtendedEntry.PlaceholderTextColorProperty, Value = Color.Purple},

                }
//.........这里部分代码省略.........
开发者ID:Railgun-it,项目名称:autoresolve-app,代码行数:101,代码来源:App.cs

示例13: Update

 public static void Update(ResourceDictionary resources)
 {
     resources.Add("LocalizedStrings", new LocalizedStrings());
     resources.Add("ViewModelLocator", new ViewModelLocator(ServiceLocator.Resolve<IContainer>()));
     resources.Add("DeviceSpecificsLocator", new DeviceSpecificsLocator(ServiceLocator.Resolve<IContainer>()));
 }
开发者ID:johanlindfors,项目名称:AssemblySplitting,代码行数:6,代码来源:ResourcesProvider.cs

示例14: SetupTheme

        public static void SetupTheme(bool reload = true)
        {
            var _ColorString = StorageHelper.GetSetting(Contracts.Settings.PrimaryColor, Contracts.Settings.DefaultColor);

            Uri _Path = null;
            if (_ColorString.Equals(Windows.UI.Colors.Red.ToString()))
                _Path = new Uri("ms-appx:/Styles/CustomStyles.Red.xaml");
            else if (_ColorString.Equals(Windows.UI.Colors.Green.ToString()))
                _Path = new Uri("ms-appx:/Styles/CustomStyles.Green.xaml");
            else if (_ColorString.Equals(Windows.UI.Colors.Blue.ToString()))
                _Path = new Uri("ms-appx:/Styles/CustomStyles.Blue.xaml");
            else if (_ColorString.Equals(Windows.UI.Colors.Orange.ToString()))
                _Path = new Uri("ms-appx:/Styles/CustomStyles.Orange.xaml");

            var _Standard = new ResourceDictionary { Source = new Uri("ms-appx:/Styles/StandardStyles.xaml") };
            var _Custom = new ResourceDictionary { Source = _Path };
            var _Main = new ResourceDictionary { MergedDictionaries = { _Standard, _Custom } };
            foreach (var item in App.Current.Resources)
            {
                if (!_Main.ContainsKey(item.Key))
                    _Main.Add(item);
            }
            App.Current.Resources = _Main;

            // refresh the style immediately
            if (reload)
                Services.Navigation.Reload();
        }
开发者ID:noriike,项目名称:xaml-106136,代码行数:28,代码来源:Splash.xaml.cs

示例15: DynamicStylesPageCS

		public DynamicStylesPageCS ()
		{
			Title = "Dynamic";
			Icon = "csharp.png";
			Padding = new Thickness (0, 20, 0, 0);

			var baseStyle = new Style (typeof(View)) {
				Setters = {
					new Setter {
						Property = View.VerticalOptionsProperty,
						Value = LayoutOptions.CenterAndExpand
					}
				}
			};

			var blueSearchBarStyle = new Style (typeof(SearchBar)) {
				BasedOn = baseStyle,
				Setters = {
					new Setter {
						Property = SearchBar.FontAttributesProperty,
						Value = FontAttributes.Italic
					},
					new Setter {
						Property = SearchBar.PlaceholderColorProperty,
						Value = Color.Blue
					} 
				}	
			};

			var greenSearchBarStyle = new Style (typeof(SearchBar)) {
				Setters = {
					new Setter {
						Property = SearchBar.FontAttributesProperty,
						Value = FontAttributes.None
					},
					new Setter {
						Property = SearchBar.PlaceholderColorProperty,
						Value = Color.Green
					}
				}	
			};

			var buttonStyle = new Style (typeof(Button)) {
				BasedOn = baseStyle,
				Setters = {
					new Setter {
						Property = Button.FontSizeProperty,
						Value = Device.GetNamedSize (NamedSize.Large, typeof(Button))
					},
					new Setter {
						Property = Button.TextColorProperty,
						Value = Color.Red
					} 
				}	
			};					

			var searchBar1 = new SearchBar { Placeholder = "These SearchBar controls" };
			searchBar1.SetDynamicResource (VisualElement.StyleProperty, "searchBarStyle");
			var searchBar2 = new SearchBar { Placeholder = "are demonstrating" };
			searchBar2.SetDynamicResource (VisualElement.StyleProperty, "searchBarStyle");
			var searchBar3 = new SearchBar { Placeholder = "dynamic styles, " };
			searchBar3.SetDynamicResource (VisualElement.StyleProperty, "searchBarStyle");
			var searchBar4 = new SearchBar { Placeholder = "but this isn't dynamic", Style = blueSearchBarStyle };

			var button = new Button { Text = "Change Style", Style = buttonStyle };
			button.Clicked += OnButtonClicked;

			Resources = new ResourceDictionary ();
			Resources.Add ("blueSearchBarStyle", blueSearchBarStyle);
			Resources.Add ("greenSearchBarStyle", greenSearchBarStyle);
			Resources ["searchBarStyle"] = Resources ["blueSearchBarStyle"];

			Content = new StackLayout { 
				Children = {
					searchBar1,
					searchBar2,
					searchBar3,
					searchBar4,
					button
				}
			};
		}
开发者ID:ChandrakanthBCK,项目名称:xamarin-forms-samples,代码行数:82,代码来源:DynamicStylesPageCS.cs


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