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


C# ResourceDictionary类代码示例

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


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

示例1: GetSystemResources

		public IResourceDictionary GetSystemResources()
		{
			_dictionary = new ResourceDictionary();
			UpdateStyles();

			return _dictionary;
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:7,代码来源:ResourcesProvider.cs

示例2: BasicStyleCodePage

        public BasicStyleCodePage()
        {
            Resources = new ResourceDictionary
            {
                { "buttonStyle", new Style(typeof(Button))
                    {
                        Setters = 
                        {
                            new Setter
                            {
                                Property = View.HorizontalOptionsProperty,
                                Value = LayoutOptions.Center
                            },
                            new Setter 
                            {
                                Property = View.VerticalOptionsProperty,
                                Value = LayoutOptions.CenterAndExpand
                            },
                            new Setter
                            {
                                Property = Button.BorderWidthProperty,
                                Value = 3
                            },
                            new Setter
                            {
                                Property = Button.TextColorProperty,
                                Value = Color.Red
                            },
                            new Setter
                            {
                                Property = Button.FontSizeProperty,
                                Value = Device.GetNamedSize(NamedSize.Large, typeof(Button))
                            }
                        }
                    }
                }
            };

            Content = new StackLayout
            {
                Children = 
                {
                    new Button
                    {
                        Text = " Do this! ",
                        Style = (Style)Resources["buttonStyle"]
                    },
                    new Button
                    {
                        Text = " Do that! ",
                        Style = (Style)Resources["buttonStyle"]
                    },
                    new Button
                    {
                        Text = " Do the other thing! ",
                        Style = (Style)Resources["buttonStyle"]
                    }
                }
            };
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:60,代码来源:BasicStyleCodePage.cs

示例3: LoadSettings

        public static void LoadSettings()
        {
            // Load all available themes
            Themes = new List<Theme>();
            var blue = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Blue.xaml") };
            var blueTheme = new Theme { Resource = blue };
            var black = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Black.xaml") };
            var blackTheme = new Theme { Resource = black };
            var red = new ResourceDictionary { Source = new Uri("ms-appx:///Themes/Red.xaml") };
            var redTheme = new Theme { Resource = red };
            Themes.Add(blueTheme);
            Themes.Add(blackTheme);
            Themes.Add(redTheme);

            // Load Theme
            var setTheme = new Theme();
            var localSettings = ApplicationData.Current.LocalSettings;
            var theme = localSettings.Values["Theme"];
            if (theme == null)
            {
                // Theme not set so default to Black
                var resource = new ResourceDictionary { Source = new System.Uri("ms-appx:///Themes/Black.xaml") };
                setTheme.Resource = resource;
            }

            else
            {
                var resource = new ResourceDictionary { Source = new System.Uri(theme.ToString()) };
                setTheme.Resource = resource;
            }
            Theme = setTheme;
        }
开发者ID:nathanashton,项目名称:BookieUWP,代码行数:32,代码来源:BookieSettings.cs

示例4: OnLaunched

        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        async protected override void OnLaunched(LaunchActivatedEventArgs args)
        {

            // based upon the "use app branding" load in new themes
            ResourceDictionary appBranding = new ResourceDictionary();
            appBranding.Source = new System.Uri("ms-appx:///DesertBranding.xaml");

            this.Resources.MergedDictionaries.Add(appBranding);

            this.LaunchArgs = args;

            Frame rootFrame = null;
            if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                // Do an asynchronous restore
                await SuspensionManager.RestoreAsync();
            }
            if (Window.Current.Content == null)
            {
                rootFrame = new Frame();
                rootFrame.Navigate(typeof(MainPage));
                Window.Current.Content = rootFrame;
            }
            Window.Current.Activate();
        }
开发者ID:mbin,项目名称:Win81App,代码行数:31,代码来源:App.xaml.cs

示例5: App

        public App()
        {
            _pages = new Dictionary<ExampleViewCellModel, Type>
            {
                {new ExampleViewCellModel {Title = "Button Animation"}, typeof (ButtonPage)},
                {new ExampleViewCellModel {Title = "Paper Button Animation"}, typeof (PaperButtonPage)},
                {new ExampleViewCellModel {Title = "Password Indicator Animation"}, typeof (PasswordIndicatorPage)}
            };

            var list = new ListView
            {
                ItemTemplate = new DataTemplate(typeof (ExampleViewCell)),
                ItemsSource = _pages.Keys.ToArray(),
                RowHeight = 50
            };

            list.ItemSelected += List_ItemSelected;
            
            var rootPage = new ContentPage
            {
                Title = "Forms Animation Examples",
                Content = list
            };

            Resources = new ResourceDictionary();
            SetGlobalStyles();
            MainPage = new NavigationPage(rootPage);
        }
开发者ID:michaeled,项目名称:FormsAnimations,代码行数:28,代码来源:App.cs

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

示例7: ResourceViewModel

 public ResourceViewModel(object key, object resource, ResourceDictionary dictionary) : base(null)
 {
     this.Key = key;
     this.Name = key.ToString();
     _dictionary = dictionary;
     this.Value = resource;
     this.PropertyType = _value.GetType();
 }
开发者ID:xyzzer,项目名称:WinRTXamlToolkit,代码行数:8,代码来源:ResourceViewModel.cs

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

示例9: ApplyTheme

        private void ApplyTheme(Theme theme) {
            var uri = new Uri($"ms-appx:///Styles/{theme}.xaml", UriKind.Absolute);
            var resourceDictionary = new ResourceDictionary {
                Source = uri
            };

            Resources.MergedDictionaries.Add(resourceDictionary);
        }
开发者ID:acedened,项目名称:TheChan,代码行数:8,代码来源:App.xaml.cs

示例10: DynamicVsStaticCodePage

        public DynamicVsStaticCodePage()
        {
            Padding = new Thickness(5, 0);

            // Create resource dictionary and add item.
            Resources = new ResourceDictionary
            {
                { "currentDateTime", "Not actually a DateTime" }
            };

            Content = new StackLayout
            {
                Children = 
                {
                    new Label
                    {
                        Text = "StaticResource on Label.Text:",
                        VerticalOptions = LayoutOptions.EndAndExpand,
                        FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                    },

                    new Label
                    {
                        Text = (string)Resources["currentDateTime"],
                        VerticalOptions = LayoutOptions.StartAndExpand,
                        HorizontalTextAlignment = TextAlignment.Center,
                        FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                    },

                    new Label
                    {
                        Text = "DynamicResource on Label.Text:",
                        VerticalOptions = LayoutOptions.EndAndExpand,
                        FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                    }
                }
            };

            // Create the final label with the dynamic resource.
            Label label = new Label
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            label.SetDynamicResource(Label.TextProperty, "currentDateTime");

            ((StackLayout)Content).Children.Add(label);

            // Start the timer going.
            Device.StartTimer(TimeSpan.FromSeconds(1),
                () =>
                {
                    Resources["currentDateTime"] = DateTime.Now.ToString();
                    return true;
                });
        }
开发者ID:jenart,项目名称:xamarin-forms-book-preview-2,代码行数:58,代码来源:DynamicVsStaticCodePage.cs

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

示例12: LoadState

 /// <summary>
 /// 使用在导航过程中传递的内容填充页。在从以前的会话
 /// 重新创建页时,也会提供任何已保存状态。
 /// </summary>
 /// <param name="navigationParameter">最初请求此页时传递给
 /// <see cref="Frame.Navigate(Type, Object)"/> 的参数值。
 /// </param>
 /// <param name="pageState">此页在以前会话期间保留的状态
 /// 字典。首次访问页面时为 null。</param>
 protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
 {
     // TODO: 创建适用于问题域的合适数据模型以替换示例数据
     ResourceDictionary res = new ResourceDictionary();
     res.Source = new Uri("ms-appx:///Common/StandardStyles.xaml", UriKind.Absolute);
     SampleDataSource.Resources = res;
     var sampleDataGroups = SampleDataSource.GetGroups((String)navigationParameter);
     this.DefaultViewModel["Groups"] = sampleDataGroups;
 }
开发者ID:SuperMap,项目名称:iClient-WP8-Example,代码行数:18,代码来源:GroupedItemsPage.xaml.cs

示例13: SetMergedDictionaries

        public static void SetMergedDictionaries(DependencyObject d, ResourceDictionary dictionary)
        {
            if(d == null)
            {
                throw new ArgumentNullException("d");
            }

            d.SetValue(MergedDictionariesProperty, dictionary);
        }
开发者ID:knifhen,项目名称:buttercup-swedish,代码行数:9,代码来源:ResourceDictionary.cs

示例14: ChangeTheme

 void ChangeTheme(Uri theme)
 {
     var t = new ResourceDictionary { Source = theme };
     var r = new ResourceDictionary { MergedDictionaries = { t } };
     App.Current.Resources = r;
     var f = (Window.Current.Content as Frame);
     f.Navigate(f.Content.GetType());
     f.GoBack();
 }
开发者ID:noriike,项目名称:xaml-106136,代码行数:9,代码来源:Settings.xaml.cs

示例15: SampleDataCommon

 public SampleDataCommon(String uniqueId, String title, String subtitle, String imageItemsPath, String imageGroupsPath, String description, ResourceDictionary res, String brushPath)
 {
     this._uniqueId = uniqueId;
     this._title = title;
     this._subtitle = subtitle;
     this._description = description;
     this._imageItemsPath = imageItemsPath;
     this._imageGroupsPath = imageGroupsPath;
     this._resources = res;
     this._brushPath = brushPath;
 }
开发者ID:SuperMap,项目名称:iClient-WP8-Example,代码行数:11,代码来源:SampleDataSource.cs


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