System.Windows.DependencyObject.CoerceValue C# (CSharp) Method

CoerceValue() public method

public CoerceValue ( DependencyProperty dp ) : void
dp DependencyProperty
return void
        public void CoerceValue(DependencyProperty dp)
        {
            PropertyMetadata pm = dp.GetMetadata (this);
            if (pm.CoerceValueCallback != null)
                pm.CoerceValueCallback (this, GetValue (dp));
        }

Usage Example

Example #1
0
		static void OnTimeSpanPropertyChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
		{
			
			TimePicker timePicker = dp as TimePicker;

			if (e.Property == TimeSpanProperty)
			{
				if (timePicker != null)
				{
					if (timePicker.TimeSpan.Days > 0)
					{
						if (timePicker.IsFullDay)
							timePicker.TextBox.Text = "24:00";
						else timePicker.TextBox.Text = "23:59";
					}
					else timePicker.TextBox.Text = timePicker.TimeSpan.Hours.ToString("D2") + ":" + timePicker.TimeSpan.Minutes.ToString("D2");
				}
				dp.CoerceValue(TimeSpanProperty);
			}
		}
All Usage Examples Of System.Windows.DependencyObject::CoerceValue