我有一个资源字典,我在其中添加了代码隐藏。
在资源词典中,我有一个组合框。 我想将该组合框的 ItemsSource 绑定到代码隐藏中的列表。
如何设置绑定的源,使其在代码隐藏中查找?
This one uses the code behind --------+
|
V
<ComboBox PreviewKeyDown="CustomItem_PreviewKeyDown"
ItemsSource="{Binding AllItems, Source={CodeBehind} />
^ ^
| |
But this one doesn't | because the source is not correct |
如果它很重要,这就是我的资源字典的开头的样子:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyProject.MyCodeBehindClass"
x:Name="ANameThatSeemsUselessHere">
关于如何将 ItemSource 绑定到 ResourceDictionary 代码隐藏的任何想法?
我认为它是这样的 DataContext ="{Static Resource ANameTheSeemsUsl