Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to create a textbox and combobox for an optional parameter. the header contains a checkbox to check and the control is enabled to fill the value
if the checkbox is not checked, the parameter won{t be used

What I have tried:

<TextBox x:Name="TXT_Identifier" IsEnabled="{Binding ElementName=CHK_Identifier, Path=IsChecked}" PlaceholderText="Identifier" Margin="0,24,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top">
      <TextBox.Header>
         <CheckBox x:Name="CHK_Identifier" Content="Identifier" />
      </TextBox.Header>
   </TextBox>


The issue is the checkbox is part of the component so the checkbox is disabled too.
Posted
Updated 30-Apr-20 10:32am
v2

1 solution

I found a solution by myselves. Just switch checkbox and Textbox

<CheckBox x:Name="CHK_Identifier" VerticalAlignment="Center">
   <CheckBox.Content>
      <TextBox x:Name="TXT_Identifier" Header="Identifier" IsEnabled="{Binding ElementName=CHK_Identifier, Path=IsChecked}" PlaceholderText="Identifier" />
   </CheckBox.Content>
</CheckBox>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900