Пример #1
0
        /// <summary>
        /// Handles the Gender value property changed event.
        /// </summary>
        /// <param name="d">Gender label whose gender has changed.</param>
        /// <param name="e">Instance of <see cref="System.Windows.DependencyPropertyChangedEventArgs"/> containing the data.</param>
        private static void OnGenderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.OldValue != e.NewValue)
            {
                GenderLabel genderLabel = d as GenderLabel;
                if (genderLabel != null || !typeof(GenderLabel).IsInstanceOfType(genderLabel))
                {
                    if (e.Property == ValueProperty)
                    {
                        if (Enum.IsDefined(typeof(PatientGender), e.NewValue))
                        {
                            genderLabel.CanChangeDisplayValue = true;
                            genderLabel.SetValue(DisplayValueProperty, genderLabel.GetDisplayText());
                            genderLabel.CanChangeDisplayValue = false;
                        }
                        else
                        {
                            genderLabel.Value = PatientGender.NotKnown;
                        }
                    }

                    GenderLabelAutomationPeer peer;
#if SILVERLIGHT
                    peer = FrameworkElementAutomationPeer.FromElement(genderLabel) as GenderLabelAutomationPeer;
#else
                    peer = UIElementAutomationPeer.FromElement(genderLabel) as GenderLabelAutomationPeer;
#endif

                    if (peer != null)
                    {
                        peer.RaiseValueChangedEvent(e.OldValue.ToString(), e.NewValue.ToString());
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a new instance of gender label automation peer.
 /// </summary>
 /// <param name="control">Gender label control.</param>
 public GenderLabelAutomationPeer(GenderLabel control)
     : base(control)
 {
 }