c# - Binding attached property to IEnumerable -


i using new wpf viewer crystal reports in c#. using mvvm, bind source of data displayed instead of doing in loaded event. therefore, wanted implement attached property source - binding doesn't work, getter method not called. other posts binding attached properties didn't , not sure doing different. can help? here simplified code attached property:

public static class crystalreportsattached {     public static readonly dependencyproperty sourceproperty =         dependencyproperty.registerattached(             "source",             typeof(ienumerable),             typeof(crystalreportsattached),             new uipropertymetadata(new observablelist<participant>() ienumerable, sourcechanged));      public static void setsource(dependencyobject target, ienumerable value) {         target.setvalue(sourceproperty, value);     }      public static ienumerable getsource(dependencyobject target) {         return (ienumerable)target.getvalue(sourceproperty);     }      private static void sourcechanged(dependencyobject d, dependencypropertychangedeventargs e) {         crystalreportsviewer reportviewer = d crystalreportsviewer;         if (reportviewer != null) {             mycrystalreport report = new mycrystalreport();             report.setdatasource(d.getvalue(sourceproperty) ienumerable);             reportviewer.viewercore.reportsource = report;         }     } } 

where mycrystalreport wrapper around rpt report file.

if bind source now, it's not working:

<my:crystalreportsviewer prop:crystalreportsattached.source="{binding mylist, mode=oneway}"/> 

i tried bind datagrids itemssource in same way , works, there seems no mistake path name or smth similar.

any appreciated. lot!

with dependency properties, can ever of property changed callback called when property changes , underlying property changed if getter called. might seem strange getter , setter access underlying property, if xaml parser calls target.getvalue(sourceproperty) gets correct thing without calling getter.

the real question property changed callback called?


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -