Command Binding WPF VB.NET -
help me resolve command binding issue i'm having toggleheightmeasurementon property (see code below). reasons, content binding working, command not binding.
view code
<usercontrol x:class="heightmeasurementselector" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:common="clr-namespace:harvestercore;assembly=harvestercore" mc:ignorable="d" d:designheight="85" d:designwidth="550" fontsize="16"> <grid > <grid.columndefinitions> <columndefinition width="40*"/> <columndefinition width="100*"/> <columndefinition width="40*"/> <columndefinition width="100*"/> <columndefinition width="50*"/> <columndefinition width="120*"/> <columndefinition width="30*"/> </grid.columndefinitions> <grid.rowdefinitions> <rowdefinition/> </grid.rowdefinitions> <button content="{binding heightmeasurementon,mode=oneway}" command="{binding toggleheightmeasurementon, mode=oneway}" style="{dynamicresource metrobutton}" background="{binding heightmeasurementon,mode=oneway,converter={staticresource backgroundcvtr}}" fontweight="bold" grid.column="0" margin="2"/> <label content="earheight" horizontalalignment="center" verticalalignment="center" grid.column="1" style="{dynamicresource boldlabel}"/> <label content="{binding heightmeasurementprismname, mode=oneway}" style="{dynamicresource boldlabel}" verticalalignment="center" visibility="{binding heightmeasurementon, mode=oneway}" horizontalalignment="center" grid.column="3"/> <label content="{binding heightmeasurementonuom, mode=oneway}" style="{dynamicresource boldlabel}" verticalalignment="center" visibility="{binding heightmeasurementon, mode=oneway, converter={staticresource converter}}" horizontalalignment="center" grid.column="5"/> </grid> </usercontrol>
code behind
public class heightmeasurementselector public sub new(vm heightmeasurementviewmodel) initializecomponent() me.datacontext = vm end sub end class
viewmodel code
public class heightmeasurementviewmodel inherits viewmodelbase private model heightmeasurementmodel public sub new(model heightmeasurementmodel) me.model = model end sub public readonly property heightmeasurementon boolean return model.heightmeasurementon end end property public readonly property toggleheightmeasurementon icommand return new delegatecommand(sub() model.heightmeasurementon = not model.heightmeasurementon end sub) end end property end class
model code
private earhton boolean public property heightmeasurementon boolean return earhton end set(value boolean) earhton = value if earhton taker.visualtrait_on() elseif (not heightmeasurementon ) andalso (not plantheighton) andalso (not vtmodel.visualtraitactive) taker.visualtrait_off() end if raiseevent earheightonchanged(heightmeasurementon) raiseevent dialogonchanged(dialogon) end set end property
Comments
Post a Comment