diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs index 79afdfaab..b1e7080fc 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchToggleSlider.cs @@ -105,6 +105,48 @@ namespace Tango.Touch.Controls } public static readonly DependencyProperty CheckedThumbContentTemplateProperty = DependencyProperty.Register("CheckedThumbContentTemplate", typeof(DataTemplate), typeof(TouchToggleSlider), new PropertyMetadata(null)); + + public String LeftText + { + get { return (String)GetValue(LeftTextProperty); } + set { SetValue(LeftTextProperty, value); } + } + + public static readonly DependencyProperty LeftTextProperty = + DependencyProperty.Register("LeftText", typeof(String), typeof(TouchToggleSlider), new PropertyMetadata("")); + + public CornerRadius ThumbCornerRadius + { + get { return (CornerRadius)GetValue(ThumbCornerRadiusProperty); } + set { SetValue(ThumbCornerRadiusProperty, value); } + } + public static readonly DependencyProperty ThumbCornerRadiusProperty = + DependencyProperty.Register("ThumbCornerRadius", typeof(CornerRadius), typeof(TouchToggleSlider), new PropertyMetadata(default(CornerRadius))); + + public String RightText + { + get { return (String)GetValue(RightTextProperty); } + set { SetValue(RightTextProperty, value); } + } + + // Using a DependencyProperty as the backing store for RightText. This enables animation, styling, binding, etc... + public static readonly DependencyProperty RightTextProperty = + DependencyProperty.Register("RightText", typeof(String), typeof(TouchToggleSlider), new PropertyMetadata("")); + + + + public int ThumbWidth + { + get { return (int)GetValue(ThumbWidthProperty); } + set { SetValue(ThumbWidthProperty, value); } + } + + // Using a DependencyProperty as the backing store for ThumbWidth. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ThumbWidthProperty = + DependencyProperty.Register("ThumbWidth", typeof(int), typeof(TouchToggleSlider), new PropertyMetadata(0)); + + + public TouchToggleSlider() { @@ -120,6 +162,7 @@ namespace Tango.Touch.Controls { base.OnApplyTemplate(); _grid_ellipse = GetTemplateChild("PART_GridEllipse") as Grid; + SetThumbPosition(); } protected override void OnChecked(RoutedEventArgs e) @@ -143,7 +186,15 @@ namespace Tango.Touch.Controls if (IsChecked.Value) { - ani.To = new Thickness(ActualWidth - _grid_ellipse.ActualWidth - 4, 0, 0, 0); + if (ActualWidth != 0 && _grid_ellipse.ActualWidth == 0) + { + ani.To = new Thickness(ActualWidth - (ActualWidth/2) - 4, 0, 0, 0); + } + else + { + ani.To = new Thickness(ActualWidth - _grid_ellipse.ActualWidth - 4, 0, 0, 0); + } + } else { |
