在我的主/详细场景中,我有一个数据网格作为主数据网格,一个 UserControl 作为子数据网格。 当在主网格中选择特定行时,我将其分配给用户控件的 DataContext。 在我的用户控件中,我有几个 DataTemplates 作为资源,ContentControl 作为子容器。我正在努力解决的是如何根据 UserControl 的 DataContext 的属性 TemplateName 动态选择 ContentControl 的 ContentTemplate。
<ContentControl ContentTemplate="{Binding Source={StaticResource ????}}" Content="{Binding}"/>
最佳答案
对于 SL here is the link on Silverlight DataTemplateSelector这应该有助于解决问题。
关于silverlight - Silverlight 4 中基于 DataContext 的 ContentTemplate 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3211457/