无法绑定ContextPresenter.ContentTemplate

时间:2013-08-18 06:10:15

标签: wpf mvvm binding datatemplate contentpresenter

我想绑定ContentTemplateProperty的{​​{1}}:

ContentPresenter

视图模型:

<UserControl x:Class="MVVM.WPF.View.ControlViews.ParametersControlView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
         <ContentPresenter Grid.Row="2" Grid.ColumnSpan="3"
                 Content="{Binding ExtraConsole.ViewModel, UpdateSourceTrigger=PropertyChanged}"
                 ContentTemplate="{Binding Source=ExtraConsole.DataTemplate, UpdateSourceTrigger=PropertyChanged}"/>

所有其他绑定控件更新正确,ExtraConsole类中的ExtraConsole,ViewModel和DataContext的值通知为更改但是 我更改了public class ParametersGenericViewModel : ParametersViewModel { public ParametersGenericViewModel() { DataTemplate = (DataTemplate)new ResourceDictionary { Source = new Uri(DataTemplateAddresses.Parameters, UriKind.Absolute) }[DataTemplateKeys.Parameters]; } ParametersConsole extraConsole; public ParametersConsole ExtraConsole { get { return extraConsole; } set { extraConsole = value; RaisePropertyChanged("ExtraConsole"); } } ExtraConsole.DataTemplate Notify

Property Changed没有发生任何变化。

有什么建议吗?

0 个答案:

没有答案