c# - Combobox binding to Deep Properties with Caliburn.Micro -


my vm has property of model, authorization, has property of activeservice.

public authorization authorization     {                 {             return this.authorization;         }         set         {             this.authorization = value;             notifyofpropertychange();         }     } 

i created additional property on viewmodel, called services populate dropdown with:

    public ilist<service> services     {         { return services; }         set         {             services = value;             notifyofpropertychange();         }     } 

my view has combobox control named services. understanding of caliburn , it's conventions should work. doesn't display items correctly. has right number of items in list shows "cannot find view models.service"

any on i'm doing wrong?

edit

so tried this; manually set displaymemberpath binding so:

displaymemberpath="{binding authorization_activeservice_description}" 

and added override service object on tostring() so:

        public override string tostring()     {         return string.format("{0}", this.description);     } 

this works, in displays description in dropdown. i'm little confused though. able remove _description , works same. if remove override doesn't work @ all.

why doesn't deep binding description property?

by default, itemscontrol (such combobox), if itemtemplate has not been set, caliburn.micro set itemtemplate default implementation uses contentcontrol view injection, assumes each item in bound collection view model, , want define view bind view model.

if don't want define view, rather define itemtemplate in combobox markup, can, e.g:

<combobox x:name="services">     <combobox.itemtemplate>         <datatemplate>             <stackpanel>                 <textbox text="{binding name}" />                 <textbox text="{binding anotherserviceproperty}" />                               </stackpanel>         </datatemplate>     </combobox.itemtemplate> </combobox> 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -