c# - Binding.UpdateSourceTrigger giving XamlParseException/TargetInvocationException in WPF -
i'm trying apply trigger follows:
using smartrouteplanner.models; ... map locationmap = new map(); locationtextbox.datacontext = locationmap; binding locationbinding = new binding("location"); locationtextbox.setbinding(textbox.textproperty, locationbinding); locationbinding.updatesourcetrigger = updatesourcetrigger.explicit;
and xaml code this:
... xmlns:models="clr-namespace:smartrouteplanner.models" ... <grid.resources> <models:map x:key="mapdatasource"/> </grid.resources> <grid.datacontext> <binding source="{staticresource mapdatasource}" /> </grid.datacontext> <textbox x:name="locationtextbox" />
what causing exceptions?
in xaml should this:
<window x:class="teste.window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="window1" height="300" width="300"> <grid> <textbox text="{binding propertyfromdatacontext, updatesourcetrigger=explicit}" /> </grid> </window>
remember bind property datacontext
!
Comments
Post a Comment