wpf - Why can't i bind a DataGrid SelectedItem to a DependencyProperty Inside a usercontrol? -


i want bind datagrid selecteditem inside user control dependencyproperty , code:

in user control(datagridcontrol):

        public static readonly dependencyproperty datagridselecteditemproperty         = dependencyproperty.register(         "datagridselecteditem"         , typeof(object)         , typeof(datagridselectorcontrol)         , new uipropertymetadata(null));      public object datagridselecteditem     {         { return (object)getvalue(datagridselecteditemproperty); }         set { setvalue(datagridselecteditemproperty, value); }     }    <datagrid itemssource="{binding source={staticresource thesource}}"             selecteditem="{binding elementname=datagridcontrol,path=datagridselecteditem,updatesourcetrigger=propertychanged}"  /> 

and in viewmodel:

    object projectselecteditem;     public object projectselecteditem     {                 {             return projectselecteditem;         }         set         {             projectselecteditem = value;             raisepropertychanged("projectselecteditem");         }     } 

and in view:

<mvvmcommoncontrol:datagridcontrol  datagridselecteditem="{binding projectselecteditem}"  datagriddatacollection="{binding datacollection}"/> 

but dosen't work!!

you have following in user control:

 selecteditem="{binding elementname=datagridcontrol, 

but user control named datagridcontrol?

<usercontrol   ...   x:name="datagridcontrol"> 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -