I'm a complete .NET/C# nublet. I've inherited some code that defines the UI for a window with XAML and I'm trying to interface with some existing XML garbage. This is probably a very simple question; I just don't know what to Google.
I have a TextBox that I want to disable based on a boolean. I can do that with this code:
Listing A:
<TextBox x:Name="ServerNameTextBox" ... IsEnabled="{Binding ServerName.Editable}" />
The problem comes when I want to base it on a variable and a checkbox. I've already read about IMultiValueConverter and wrote one for this, but I'm not sure how to specify the bindings because the format changes.
Listing B:
<TextBox x:Name="ServerNameTextBox" ... >
<TextBox.IsEnabled>
<Binding ElementName="CheckBoxServerNameEnabled" Path="IsChecked" />
<Binding ??? />
</TextBox.IsEnabled>
</TextBox>
In order to make the same reference that's made in the first line, what needs to go in the question marks? Bonus points for telling me what the type of binding using in Listing A is called.
Thanks!
{Binding ServerName.Editable}
is (in this case) equivalent to {Binding Path=ServerName.Editable}
So in your MultiBinding
you have
<MultiBinding Converter="...">
<Binding ElementName="CheckBoxServerNameEnabled" Path="IsChecked"/>
<Binding Path="ServerName.Editable"/>
</MultiBinding>
In markup extensions the unnamed arguments are passed to the constructor, Binding
has a constructor which takes a path.