How to define a static wpf ressource from c# project settings (properties) defined in another project

541 views Asked by At

The following piece of code located in App.xaml defines a static application-wide resource, which I sucessfully binded to a listbox control.

<Application x:Class="cviko.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:properties="clr-namespace:cviko.Properties"
         StartupUri="MainWindow.xaml">
    <Application.Resources>
        <CollectionViewSource x:Key="SStrings"
             Source="{Binding Source={x:Static properties:Settings.Default}, Path=Strings}">
        </CollectionViewSource>
    </Application.Resources>

I, however, want to do the same, but instead use properties defined in another project. Something like this (not compilable):

<Application x:Class="cviko.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:properties="clr-namespace:cviko.Properties"
         //NEW
         xmlns:props="clr-namespace:UIComponents.Properties" 
         StartupUri="MainWindow.xaml">
    <Application.Resources>
        //MODIFIED
        <CollectionViewSource x:Key="SStrings"
             Source="{Binding Source={x:Static props:Settings.Default}, Path=Nums}">
        </CollectionViewSource>
</Application.Resources>

Any advice is welcome, thanks.

1

There are 1 answers

0
Tedd Parsile On BEST ANSWER

Omg, I figured it out immediately after posting:

1) I needed to use this:

xmlns:props="clr-namespace:UIComponents.Properties;assembly=UIComponents"

2) And most importantly: it was necessary to set settings to public, which I overlooked.