1

App.xaml にある次のコードは、アプリケーション全体の静的リソースを定義し、リストボックス コントロールに正常にバインドしました。

<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>

ただし、同じことをしたいのですが、代わりに別のプロジェクトで定義されたプロパティを使用します。このようなもの(コンパイル不可):

<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>

どんなアドバイスでも大歓迎です、ありがとう。

4

1 に答える 1

2

ああ、私は投稿した直後にそれを理解しました:

1)これを使用する必要がありました:

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

2) そして最も重要なこと: 設定を public に設定する必要がありましたが、これは見落としていました。

于 2017-01-02T21:31:57.843 に答える