本文整理汇总了C#中ResourceDictionary类的典型用法代码示例。如果您正苦于以下问题:C# ResourceDictionary类的具体用法?C# ResourceDictionary怎么用?C# ResourceDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResourceDictionary类属于命名空间,在下文中一共展示了ResourceDictionary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSystemResources
public IResourceDictionary GetSystemResources()
{
_dictionary = new ResourceDictionary();
UpdateStyles();
return _dictionary;
}
示例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"]
}
}
};
}
示例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;
}
示例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();
}
示例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);
}
示例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" },
}
};
}
示例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();
}
示例8: CustomEasingSwellPage
public CustomEasingSwellPage()
{
Resources = new ResourceDictionary();
Resources.Add("customEase", new Easing(t => -6 * t * t + 7 * t));
InitializeComponent();
}
示例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);
}
示例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;
});
}
示例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;
}
示例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;
}
示例13: SetMergedDictionaries
public static void SetMergedDictionaries(DependencyObject d, ResourceDictionary dictionary)
{
if(d == null)
{
throw new ArgumentNullException("d");
}
d.SetValue(MergedDictionariesProperty, dictionary);
}
示例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();
}
示例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;
}