Hi, need help with MultiBinding. My project opens a COMM port but only allows opening if all comm parameters have been chosen. Each comm parameter has its own pre-loaded ComboBox, with item 0 meaning no valid choice made, while other items have valid choices for that combo.
My OpenPort button has this XAML:
<Button Name="btnOpenPort" Content="Open Port" Width="70" Margin="30,0,0,0"><Button.IsEnabled><MultiBinding Mode="OneWay" Converter="{StaticResource ValuesOverZero}"><Binding ElementName="cboBaud" Path="SelectedValue"/><Binding ElementName="cboDataBits" Path="SelectedValue"/><Binding ElementName="cboDelay" Path="SelectedValue"/><Binding ElementName="cboInterval" Path="SelectedValue"/><Binding ElementName="cboTimeout" Path="SelectedValue"/></MultiBinding></Button.IsEnabled></Button>
The "ValuesOverZero" converter returns True for any value over 0, and False otherwise.
This is working fine, and the "Open Port" button is properly disabled until I have chosen all of the communications parameters from their respective ComboBoxes.
Now, I would like to also disable the "Open Port" button when the port has been opened, and re-enable it when it has been closed. I could just do that in code-behind, but would prefer to add another binding to my MultiBinding to handle it.
I could use a dependency property to hold the state of the port. I can make the DP return 1 for open and 0 for closed, so it would fit in with the MultiBinding converter, and set it in the click event of the "Open Port" button. I can't figure out how to add a binding to my dependency property into the list of bindings contained in the MultiBinding XAML section. I've successfully bound to DP's in MultiDataTriggers before, but the syntax in MultiBinding bindings is different. I just can't figure out how to declare the binding to a DP.
The Port object does have an IsOpen property which I could bind to instead, but it's a Boolean, not a numeric of 0 or >0. Is there a way to bind directly to that IsOpen property? I would need to know how to declare it in code so my XAML would
know about it, right?
TIA for any help...
Ron Mittelman