c# - Why is ImageSource called twice in WPF? -
my app changes pictures button click. however, when watch breakpoint, imagesource's property referenced twice each time. other properties referenced once.
why imagesource "get" running twice?
specifically, line runs 2 times, back, right after propertychanged()
:
get { return picture; }
this how update image in gui:
public class applicationstate : inotifypropertychanged { public event propertychangedeventhandler propertychanged; private imagesource picture; public imagesource picture { { return picture; } set { picture = value; notifypropertychanged("picture"); } } private void notifypropertychanged(string propertyname) { if (propertychanged != null) { propertychanged(this, new propertychangedeventargs(propertyname)); } } }
this xaml code image:
<image source="{binding path=picture}"/>
and picture change triggered with:
picture = convert(picturepath);
am missing something? why ever run twice back?
edit: microsoft explains of reason in this note.
Comments
Post a Comment