1

Where would I set default values that I want to use throughout a project and only define once?

An example would be a default margin, or a color that I want to use in multiple places.

In pure C, one way to do this would be with a "defaults.h" header file with "#define"s.

mrueg
  • 8,185
  • 4
  • 44
  • 66

3 Answers3

1

You can use the appsettings section of an app.config file. See here for more info.

wsanville
  • 37,158
  • 8
  • 76
  • 101
  • What I really want is somewhat different from settings, I want to define static objects, that never change. Something like "Thickness DefaultUIMargin = new Thickness(5);" – mrueg Jan 30 '10 at 13:00
1

You can do most of this with resources and templates, if you want common looks and styles throughout your app.

Edit: Based on your comment, looking at x:Static may be what you're after. Here's a SO question covering it. If that's still not quite it...try elaborating a bit more.

This is what I first read when playing around with WPF explaining it.

Community
  • 1
  • 1
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
1

The simplest way to do this is to store them in the application's resource dictionary, either in markup (in the <Application.Resources> element in app.xaml) or by creating them in code at startup and adding them to the resource dictionary.

This allows you to do some pretty sophisticated stuff fairly easily, so long as you have a consistent application-wide naming convention for resource keys. For instance, it's easy to implement simple skinning in an application by building resource dictionaries in XAML files and then merging a specific dictionary into the application's dictionary at startup.

Robert Rossney
  • 94,622
  • 24
  • 146
  • 218