Binding Conventions not working with Telerik and Deep Properties

Topics: Conventions, Getting Started
May 21, 2013 at 1:55 PM
Not sure what I am doing wrong but here goes. I have a VM with a property on it called Authorization.

I have a View that corresponds to the VM with a bunch of controls. I have named the controls things like this: x:Name="Authorization_SelectedService_Rate" or x:Name="Authorization_Notes_Details". Now, the second one of those works but the first doesn't. By works I mean that when I go to Save the "form" my Authorization.Notes property will have a value but not my Authorizatien.SelectedService.

I've been working on this for awhile now and just can't figure out what I'm doing wrong. I would be willing to show complete View and ViewModel in hopes that someone can point out what I'm doing wrong.

Is it because I'm using Telerik Controls? I don't know...

These are truncated to make the 10000 character limit.

My View:
<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:RadGridView x:Name="Services" IsReadOnly="True" SelectionMode="Extended" ScrollViewer.CanContentScroll="True"/>
     <telerik:RadComboBox x:Name="FrequencyList" Margin="3" Grid.Column="1" Grid.Row="1" ItemTemplate="{StaticResource FrequencyBoxCustomTemplate}"/>
     <TextBox x:Name="Authorization_Notes_Details" MaxLength="500" Height="Auto" MinHeight="15" MaxHeight="40" TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" VerticalScrollBarVisibility="Auto"/>

</UserControl>
My Authorization Class:
 public class Authorization : BindableBase
    {
public Service SelectedService
        {
            get
            {
                return this.selectedService;
            }
            set
            {
                this.selectedService = value;
                OnPropertyChanged();
            }
        }

        public int ID
        {
            get
            {
                return this.id;
            }
            set
            {
                this.id = value;
                this.OnPropertyChanged();
            }
        }
        public FrequencyChoice SelectedFrequency
        {
            get
            {
                return this.selectedFrequency;
            }
            set
            {
                this.selectedFrequency = value;
                this.OnPropertyChanged();
            }
        }
public Note Notes
        {
            get
            {
                return this.notes;
            }
            set
            {
                this.notes = value;
                this.OnPropertyChanged();
            }
        }
    }
My ViewModel
    [Export(typeof(IScreen))]
    public class CreateAuthViewModel : Screen, IHandle<MessageNotifier>
    {        
        private readonly IEventAggregator eventAggregator;

        private AuthorizationRepo authRepo;

        #region CONSTRUCTOR
        [ImportingConstructor]
        public CreateAuthViewModel(IEventAggregator eAgg)
        {
            eventAggregator = eAgg;
            eventAggregator.Subscribe(this);

            this.DisplayName = "Create Authorization";
            this.Authorization = new Authorization();
            this.authRepo = new AuthorizationRepo();
            
            GetAdminData();
        }

        #endregion

        #region PROPERTIES
        
        private Authorization authorization;
        public Authorization Authorization
        {
            get
            {
                return this.authorization;
            }
            set
            {
                this.authorization = value;
                NotifyOfPropertyChange(() => Authorization);
            }
        }

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

        private BindableCollection<FrequencyChoice> frequencyList;

        public BindableCollection<FrequencyChoice> FrequencyList
        {
            get { return frequencyList; }
            set
            {
                frequencyList = value;
                NotifyOfPropertyChange();
            }
        }
}
May 23, 2013 at 5:40 PM
It does have to do with you using Telerik controls but you also need to take into account that you still have to setup some conventions for those controls from Telerik since they aren't part of the normal control set that is already "pre-conventioned" from the developers there are variances in how controls are created therefore the expected behavior is correct since TextBox is a in-the-box control that has a convention.

I suggest you read up on creating conventions for those controls there is a link on the docs page for an assembly for a few controls for Silverlight/wpf written by one of the contributors here.

https://github.com/vcaraulean/Caliburn.Micro.Telerik
May 23, 2013 at 6:56 PM
Hey, thanks for the help. I had suspected that the inclusion of Telerik was part of my problem. However it already has a convention for GridView's and the example even shows something similar to what I'm talking about. I wonder if my problem is that they show the VM having a Collection of an Object and then a "SelectedItem" version of the same object.
List<DataItem>DataItems 
DataItem SelectedDataItem   
Where I have the following,
BindableCollection<Service> Services 
Authorization Authorization
which has a Property called
Service SelectedService
so it would be Authorization.SelectedService. I'm wondering if Caliburn's Binding Convention doesn't know to look there since the Object Type is different.... Even if it's true I have no idea how to go about fixing it. it.