How to access MyProject.MySettings.Default.SomeSetting from xaml?

Posted by Shimmy on Stack Overflow See other posts from Stack Overflow or by Shimmy
Published on 2010-04-22T03:14:52Z Indexed on 2010/04/22 3:23 UTC
Read the original article Hit count: 560

I have defined a StringCollection in the Project Settings. I want to use the values in a ComboBox.

Is there a way to access it xamly?

I tried:

<CollectionViewSource Source="{x:Static src:MySettings.Default.MyCollection}" />
<CollectionViewSource x:Key="RoomSections"
    Source="{x:Static src:MySettings.Default.RoomSections}" />

*src is the xmlns of the project

It says: "Type src:MySettings.Default was not found".

The thing is that MySettings is a class that offers a Default property which is a thread-safe instance of MySettings, I really want to get the collection from the Default property and not by instantiating a new on.

Is there other ways I am not aware of, maybe ObjectDataProvider can access static objects?

I thought, maybe I can make in the App.xaml a global resource that return MySettings.Default which is an instance of the MySettings class, and then access all its properties, I will try that out, but I prefer the easy way.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about wpf