c# - Data-binding to KVP of Object,Object not allowing properties to be used or updated in real time? -


i have operation class , result class use build list, use xaml bind properties , converter return content based on properties, of works....

to make easy post xaml note works , need with.

<usercontrol x:class="operationlistview"          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             xmlns:telerik="http://schemas.telerik.com/2008/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"           mc:ignorable="d"           xmlns:prism="http://www.codeplex.com/prism"          xmlns:inf="clr-namespace:***;assembly=***"          xmlns:c="clr-namespace:****.***"          d:designheight="300" d:designwidth="300"> <control.resources>     <c:languagetextconverter x:key="langconverter" />     <c:resultviewconverter x:key="statusconverter" />     <c:opdetailviewconverter x:key="opconverter" /> </control.resources> <grid>     <grid.columndefinitions>         <columndefinition width="1*"/>     </grid.columndefinitions>     <telerik:radgridview name="operationgrid"                          grid.column="0"                          rowheight="75"                          selectionmode="single"                          selecteditem="{binding selectedoperation, mode=twoway}"                          itemssource="{binding operations}"                          isreadonly="true"                          autogeneratecolumns="false"                          rowdetailsvisibilitymode="visiblewhenselected"                          showgrouppanel="false"                          rowindicatorvisibility="collapsed" >         <telerik:radgridview.rowdetailstemplate>             <datatemplate>                 <contentcontrol grid.column="1" template="{binding converter={staticresource opconverter}}" />             </datatemplate>         </telerik:radgridview.rowdetailstemplate>         <telerik:radgridview.columns>             <telerik:gridviewdatacolumn header="name"                                         datamemberbinding="{binding key.operationname, converter={staticresource langconverter}}"                                         width="2*"                                         isgroupable="false" />             <telerik:gridviewdatacolumn header="result"                                         width="1*"                                         maxwidth="75">                  <telerik:gridviewdatacolumn.celltemplate>                     <datatemplate>                         <grid>                             <contentcontrol template="{binding value, converter={staticresource statusconverter}}"/>                         </grid>                     </datatemplate>                 </telerik:gridviewdatacolumn.celltemplate>             </telerik:gridviewdatacolumn>         </telerik:radgridview.columns>      </telerik:radgridview> </grid> 

everything final binding works, , final binding works point...

<contentcontrol template="{binding value, converter={staticresource statusconverter}}"/>    

this works, when binding value converter fires on load , loads appropriate xaml.

however no additional changes update value...

in code behind @ point value.status updated , setter on status property fires propertychanged. nothing caught on front end.

public overallstatus status     {         { return this.status; }         set { this.status = value; onpropertychanged(this, "status"); }     } 

what property syntax bind value.property (currently doesn't work @ all) , have recognize propertychanged setter 3 levels down view.

i have created sample showing nested properties. when change property value @ button click, reflected in grid. more can read here : property path syntax

<window x:class="wpfapplication1.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         title="mainwindow" height="524.627" width="862.313">     <stackpanel>         <datagrid x:name="dgrd" horizontalalignment="left" margin="10,10,0,0" verticalalignment="top" autogeneratecolumns="false">             <datagrid.columns>                 <datagridtextcolumn binding="{binding value.status.name}" clipboardcontentbinding="{x:null}" header="status"/>             </datagrid.columns>         </datagrid>         <button content="button" horizontalalignment="left" margin="29,38,0,0" grid.row="1" verticalalignment="top" width="75" click="button_click"/>      </stackpanel> </window>   using system; using system.componentmodel; using system.collections.objectmodel; using system.collections.generic; using system.windows; using system.windows.controls;  namespace wpfapplication1 {     /// <summary>     /// interaction logic mainwindow.xaml     /// </summary>     public partial class mainwindow : window     {         public mainwindow()         {               initializecomponent();              dgrd.itemssource = datastore.operations;         }          private void button_click(object sender, routedeventargs e)         {             datastore.operations[0].value.status.name = "n/a"; // change first item         }     }      public class datastore     {         //static list<operation> _operations;         public static list<operation> operations;          static datastore()         {             operations =                 new list<operation>() {                      new operation(){ value = new recordinner(){ status = new overallstatus (){ name="pending"}}},                     new operation(){ value = new recordinner(){ status = new overallstatus (){ name="started"}}},                     new operation(){ value = new recordinner(){ status = new overallstatus (){ name="completed"}}}                 };         }      }      public class operation     {         recordinner _value;         public recordinner value         {             { return _value; }             set { _value = value; }         }     }      public class recordinner     {          overallstatus _status;         public overallstatus status         {             { return _status; }             set { _status = value; }         }     }      public class overallstatus:inotifypropertychanged     {         string _name;         public string name { { return _name; } set { _name = value; onpropertychanged("name"); } }          public event propertychangedeventhandler propertychanged;         public void onpropertychanged(string name)         {             if (propertychanged != null)                 propertychanged(this, new propertychangedeventargs(name));         }     }  } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -