-
-
Save anonymous/a10df9e36bd168f9652a8546a236107f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<local:RequirementSelect Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Margin="0 5 0 0" Value="{Binding Req, Mode=TwoWay}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<UserControl x:Class="HealthNav.Views.Controls.LetterTemplate.RequirementSelect" | |
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:local="clr-namespace:HealthNav.Views.Controls.LetterTemplate" | |
mc:Ignorable="d" > | |
<Grid> | |
<StackPanel Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal"> | |
<Label Margin="0 0 5 0">Voluntary:</Label> | |
<CheckBox Name="ckbVoluntary" Margin="0 0 10 0" Checked="ckbRequirement_Checked" Unchecked="ckbRequirement_Checked" VerticalAlignment="Center" /> | |
<Label Margin="0 0 5 0">Mandatory:</Label> | |
<CheckBox Name="ckbMandatory" Checked="ckbRequirement_Checked" Unchecked="ckbRequirement_Checked" VerticalAlignment="Center" /> | |
</StackPanel> | |
</Grid> | |
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Windows; | |
using System.Windows.Controls; | |
namespace HealthNav.Views.Controls.LetterTemplate { | |
/// <summary> | |
/// Interaction logic for RequirementSelect.xaml | |
/// </summary> | |
public partial class RequirementSelect : UserControl { | |
public RequirementSelect() { | |
InitializeComponent(); | |
} | |
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register( | |
"Value", typeof(Boolean), typeof(RequirementSelect), new PropertyMetadata(false)); | |
public string Value { | |
get { | |
return (string)this.GetValue(ValueProperty); ; | |
} | |
set { | |
if (value.ToUpper().StartsWith("M")) { | |
ckbMandatory.IsChecked = true; | |
ckbVoluntary.IsChecked = false; | |
} else if (value.ToUpper().StartsWith("V")) { | |
ckbMandatory.IsChecked = false; | |
ckbVoluntary.IsChecked = true; | |
} else { | |
ckbMandatory.IsChecked = false; | |
ckbVoluntary.IsChecked = false; | |
} | |
this.SetValue(ValueProperty, value); | |
} | |
} | |
private void ckbRequirement_Checked(object sender, RoutedEventArgs e) { | |
CheckBox thisCheckbox = (CheckBox)sender; | |
if (thisCheckbox.IsChecked == true) { | |
CheckBox otherCheckbox = (thisCheckbox == ckbVoluntary ? ckbMandatory : ckbVoluntary); | |
if (otherCheckbox.IsChecked == true) { | |
SetHooks(false); | |
otherCheckbox.IsChecked = false; | |
SetHooks(true); | |
} | |
} | |
string val = "N"; | |
if (ckbVoluntary.IsChecked == true) | |
val = "V"; | |
else if (ckbMandatory.IsChecked == true) | |
val = "M"; | |
this.SetValue(ValueProperty, val); | |
} | |
private void SetHooks(bool Add) { | |
if (Add) { | |
ckbVoluntary.Checked += ckbRequirement_Checked; | |
ckbVoluntary.Unchecked += ckbRequirement_Checked; | |
ckbMandatory.Checked += ckbRequirement_Checked; | |
ckbMandatory.Unchecked += ckbRequirement_Checked; | |
} else { | |
ckbVoluntary.Checked -= ckbRequirement_Checked; | |
ckbVoluntary.Unchecked -= ckbRequirement_Checked; | |
ckbMandatory.Checked -= ckbRequirement_Checked; | |
ckbMandatory.Unchecked -= ckbRequirement_Checked; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment