Derek Kennard

Derek Kennard

  • NA
  • 55
  • 2.2k

C# Checkbox IsChecked for XAML page

Aug 5 2013 8:55 PM
This may also fall under XAML as I am just learning this langauge.

I have a basic everyday checkbox named "Pass Through"

<
CheckBox x:Name="cb" Content="Pass Through" HorizontalAlignment="Center" Margin="75,147,75,0" VerticalAlignment="Top" IsChecked="True"/>

The x:Name="cb" comes from a Windows Resource:


<Window.Resources>
   
<Style x:Key="cbTB" TargetType="{x:Type TextBox}">
      <Style.Triggers>
         <DataTrigger Binding="{Binding ElementName=cb, Path=IsChecked}" Value="True">
            <Setter Property="TextBox.IsEnabled" Value="False"/>
         </DataTrigger>
         <DataTrigger Binding="{Binding ElementName=cb, Path=IsChecked}" Value="False">
            <Setter Property="TextBox.IsEnabled" Value="True"/>
         </DataTrigger>
      </Style.Triggers>
   </Style>
</Window.Resources>
I am disabling the textbox for username and password when the checkbox is checked. That works just fine.
Now here is the problem I need your help with...

I need C# language help for the following pseudo code: If Checkbox IsChecked = true then redirect to page.xaml. I figured this has to be under the Button_Click.

private void Button_Click(object sender, RoutedEventArgs e)
   {
      If Checkbox IsChecked = true then redirect to page.xaml
   }


 

Answers (1)