wpf - Caliburn Micro: how to set binding UpdateSourceTrigger? -
i've been exploring caliburn micro mvvm framework feel it, i've run bit of problem. have textbox bound string property on viewmodel , property updated when textbox loses focus.
normally achieve setting updatesourcetrigger lostfocus on binding, don't see way within caliburn, has setup property binding me automatically. property updated every time content of textbox changes.
my code simple, instance here vm:
public class shellviewmodel : propertychangebase { private string _name; public string name { { return _name; } set { _name = value; notifyofpropertychange(() => name); } } }
and inside view have simple textbox.
<textbox x:name="name" />
how change name property updated when textbox loses focus, instead of each time property changes?
just set binding explictly instance of textbox
, caliburn.micro won't touch it:
<textbox text="{binding name, updatesourcetrigger=lostfocus}" />
alternatively, if want change default behaviour instances of textbox
, can change implementation of conventionmanager.applyupdatesourcetrigger
in bootstrapper's configure
method.
something like:
protected override void configure() { conventionmanager.applyupdatesourcetrigger = (bindableproperty, element, binding) =>{ #if silverlight applysilverlighttriggers( element, bindableproperty, x => x.getbindingexpression(bindableproperty), info, binding ); #else if (element textbox) { return; } binding.updatesourcetrigger = updatesourcetrigger.propertychanged; #endif }; }
Comments
Post a Comment