我有一个子UserControl,我无法访问其父UserControl的资源。 资源是CollectionViewSource,并且其源在父UserControl的代码后台中设置,该源设置为来自LINQ to SQL的查询结果。 两个UserControl在各自的xaml文件中定义。 我尝试使用DynamicResource,但它会抱怨说需要与DepenednecyProperty一起使用...
父UserControl:
...
<UserControl.Resources>
<CollectionViewSource x:Key="UsageTypeSource"/>
</UserControl.Resources>
...
子用户控件:
...
<ComboBox Height="28" HorizontalAlignment="Left" Margin="147,1,0,0" x:Name="cbxUsage"
Grid.Column="1" Grid.Row="2" Width="186"
SelectedItem="{Binding Path=UsageType, ValidatesOnExceptions=true, NotifyOnValidationError=true}"
VerticalAlignment="Top" SelectedValuePath="ID"
SelectedValue="{Binding Path=Usage}"
ItemsSource="{Binding Source={StaticResource UsageTypeSource}}"
DisplayMemberPath="Type"/>
...
我遇到的错误是“无法解析资源'UsageTypeSource'”,请问可以提供访问该资源的正确方法吗?谢谢! Ash
SelectedItem
和SelectedValue
真的有意义吗? - Clemens