2013-05-20 58 views
1

我只是没有弄清楚我做错了什么。我正尝试在WPF应用程序(4.5)上使用Caliburn Micro。试图遵循MVVM的价值。Deep Property与Caliburn Micro问题绑定

我的虚拟机具有服务和授权的属性。授权具有SelectedService的属性。我已经命名了我的控件x:Name=Services,当我填充它们显示在RadGridView中的服务属性时,但是当您在RadGridView中选择一个项目时,它不会将SelectedItem绑回我的SelectedService属性。是否因为服务属性是一个级别而SelectedService是更深的级别,Authorizations.SelectedService

下面是我的代码尽可能多我敢发布没有洪泛的职位。希望这已经足够了。

我觉得我很接近“获得”卡利Micro和MVVM一般....

public class Authorization:BindableBase 
{ 
    public int ID 
    { 
     get { return this.id; } 
     set 
     { 
      this.id = value; 
      this.OnPropertyChanged(); 
     } 
    } 

    public Service SelectedService 
    { 
     get { return this.selectedService; } 
     set 
     { 
      this.selectedService = value; 
      OnPropertyChanged(); 
     } 
    } 

    public Member ActiveMember 
    { 
     get { return this.activeMember; } 
     set 
     { 
      this.activeMember = value; 
      this.OnPropertyChanged(); 
     } 
    } 
} 

然后CreateAuthViewModel具有用于填充可能的选择所谓的服务是模型,也是一个属性:

[Export(typeof(IScreen))] 
public class CreateAuthViewModel : Screen, IHandle<MessageNotifier> 
{  
    public Authorization Authorization 
    { 
     get { return this.authorization; } 
     set 
     { 
      this.authorization = value; 
      NotifyOfPropertyChange(); 
     } 
    } 

    public BindableCollection<Service> Services 
    { 
     get { return services; } 
     set 
     { 
      services = value; 
      NotifyOfPropertyChange(); 
     } 
    } 

最后我看来,CreateAuthView:

<UserControl x:Name="CreateAuthUserControl" 
      x:Class="Green.Views.CreateAuthView" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
      xmlns:cal="http://www.caliburnproject.org"> 
    <telerik:RadExpander> 
    <StackPanel> 
     <telerik:RadGridView x:Name="Services" 
          IsReadOnly="True" 
          SelectionMode="Extended" 
          ScrollViewer.CanContentScroll="True" /> 
     <telerik:RadDataPager x:Name="ServicesDataPager" 
          PageSize="10" 
          VerticalAlignment="Bottom" 
          Source="{Binding Items, ElementName=Services}" /> 
    </StackPanel> 
    </telerik:RadExpander> 
</UserControl> 
+0

您的视图中的哪个位置是您的Authorization_SelectedService命名控件? – devdigital

+0

视图中没有一个。我曾经想过,在Combobox和Datagrid中,惯例是将'x:Name'绑定到虚拟机上的项目源的匹配属性,并在VM上查找名为“Selected,Active或Single”的属性和第一个属性同名。这就是我想要做的。它永远不会将Datagrid的SelectedItem设置为我的'Authorization.SelectedItem'属性。 –

+0

什么DataGrid?你有一个RadGridView和一个RadDataPager。我看不到其他任何东西。 – devdigital

回答

1

有AR e没有Telerik约定开箱,因为这需要依赖Telerik控件。您可以看看自己编写的conventions,或使用Caliburn.Micro.Telerik项目,该项目可用作NuGet package

+0

我很抱歉,我应该更清楚。我正在使用Caliburn.Micro.Telerik约定。它有RadGridView的约定,但它似乎没有工作。 –

+0

那么继续下去并不是很多。你真的填充服务属性?网格视图中是否有空白的项目?在调试时,输出窗口中是否有任何绑定错误?你的问题提到x:Name = Authorization_SelectedService,但是这在你的视图中是无处可见的。 – devdigital

+0

对不起,我会尽力而且更清楚。我将直接编辑我的文章。非常感谢你试图帮助我。 –

相关问题