wpf - MultivalueConverter not called after DragDrop -


i have imultivalueconverter updates background color of stackpanel when propertya or propertyb changed. these controls created dynamically.

problem: have added 2 stackpanels , changed propertya in code when button clicked. leads property changed event.

private void onpropertychanged([callermembername] string propertyname = null) {    if (this.propertychanged != null)    {      this.propertychanged(this, new propertychangedeventargs(propertyname));    } } 

for first stackpanel background color not updated, second stackpanel this.propertychanged inturn calls multivalueconverter , background color updated.

i not able understand why 1 control getting updated when both belong same type , eventhandler not null.

edit: if drag , drop cell value other control (devexpress datagrid) first stackpanel , change property, background not getting updated. works fine until drag , drop.

update:

 <stackpanel.background>    <multibinding converter="{staticresource resourcekey=backgroundcolorconverter}">          <binding path="propertya" updatesourcetrigger="propertychanged" />          <binding path="propertyb" updatesourcetrigger="propertychanged" />   </multibinding> </stackpanel.background> 

update 2: have tried using multidatatrigger instead of converter, couldn't solve problem.

unless miss understood you, don't see complication in doing that,

 <window.resources>         <app:backgroundcolorconverter x:key="backgroundcolorconverter"/>  </window.resources>  <grid>     <grid.rowdefinitions>         <rowdefinition height="auto"/>         <rowdefinition height="*"/>         <rowdefinition height="*"/>     </grid.rowdefinitions>     <stackpanel orientation="horizontal" >         <textbox text="{binding propertya}" width="200"/>         <textbox text="{binding propertyb}" width="200"/>     </stackpanel>     <stackpanel grid.row="1" margin="5">         <stackpanel.background>             <multibinding converter="{staticresource resourcekey=backgroundcolorconverter}">                 <binding path="propertya" updatesourcetrigger="propertychanged" />                 <binding path="propertyb" updatesourcetrigger="propertychanged" />             </multibinding>         </stackpanel.background>     </stackpanel>     <stackpanel grid.row="2" margin="5">         <stackpanel.background>             <multibinding converter="{staticresource resourcekey=backgroundcolorconverter}">                 <binding path="propertya" updatesourcetrigger="propertychanged" />                 <binding path="propertyb" updatesourcetrigger="propertychanged" />             </multibinding>         </stackpanel.background>     </stackpanel> </grid> 

the converter :

    public class backgroundcolorconverter:imultivalueconverter {     public object convert(object[] values, type targettype, object parameter, cultureinfo culture)     {         if (values==null)         {             return null;         }         return             new solidcolorbrush(color.fromrgb(byte.parse(values[0].tostring()), byte.parse(values[1].tostring()),                 50));     }      public object[] convertback(object value, type[] targettypes, object parameter, cultureinfo culture)     {         throw new notimplementedexception();     } } 

..and code behind

    public partial class mainwindow : window,inotifypropertychanged {     private byte _propertya ;     private byte _propertyb;      public byte propertya     {                 {             return _propertya;         }          set         {             if (_propertya == value)             {                 return;             }              _propertya = value;             onpropertychanged();         }     }      public byte propertyb     {                 {             return _propertyb;         }          set         {             if (_propertyb == value)             {                 return;             }              _propertyb = value;             onpropertychanged();         }     }     public mainwindow()     {         initializecomponent();         this.datacontext = this;     }      public event propertychangedeventhandler propertychanged;      [notifypropertychangedinvocator]     protected virtual void onpropertychanged([callermembername] string propertyname = null)     {         propertychangedeventhandler handler = propertychanged;         if (handler != null) handler(this, new propertychangedeventargs(propertyname));     } } 

let me know if did miss


Comments