c# - WPF Magic Strings -
so more work wpf , third party vendors infragistics, seems there 1 common practice confuses me.
why template parts have "magic strings"?
everything have been taught since inception field mvvm, decouple, no magic strings , numbers, no 1 knows else, ect...
so if that's case isn't there better way this? why accept common practice?
templating changing visual parts of control. naming way of labeling parts can referenced elsewhere.
mvvm binding data control, templating view concern, hence why templating doesn't know mvvm.
when you're changing template shouldn't need know data control bound to. if controls template data specific that's anti-pattern in opinion.
datatemplates want use data related templating. in control template you'd use presenter contentpresenter or itemspresenter give control template somewhere display data.
side note - these things set strings can defined constants, can refactor them, etc.
public class myparts { public static const string myfoo = "part_foo"; } [templatepart(name = myparts.myfoo)] <button x:name="{x:static parts:myparts.myfoo}" ... >
Comments
Post a Comment