位于 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>
欢迎任何建议,谢谢。