using System;
using System.Windows;
using System.Windows.Controls.Primitives;
namespace MaterialDesignThemes.Wpf
{
public static class ToggleButtonAssist
{
private static readonly DependencyPropertyKey HasOnContentPropertyKey =
DependencyProperty.RegisterAttachedReadOnly(
"HasOnContent", typeof(bool), typeof(ToggleButtonAssist),
new PropertyMetadata(false));
public static readonly DependencyProperty HasOnContentProperty = HasOnContentPropertyKey.DependencyProperty;
private static void SetHasOnContent(DependencyObject element, object value)
{
element.SetValue(HasOnContentPropertyKey, value);
}
///
/// Framework use only.
///
///
///
public static bool GetHasOnContent(DependencyObject element)
{
return (bool)element.GetValue(HasOnContentProperty);
}
///
/// Allows on (IsChecked) content to be provided on supporting styles.
///
public static readonly DependencyProperty OnContentProperty = DependencyProperty.RegisterAttached(
"OnContent", typeof (object), typeof (ToggleButtonAssist), new PropertyMetadata(default(object), OnContentPropertyChangedCallback));
private static void OnContentPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
SetHasOnContent(dependencyObject, dependencyPropertyChangedEventArgs.NewValue != null);
}
///
/// Allows on (IsChecked) content to be provided on supporting styles.
///
///
///
public static void SetOnContent(DependencyObject element, object value)
{
element.SetValue(OnContentProperty, value);
}
///
/// Allows on (IsChecked) content to be provided on supporting styles.
///
public static object GetOnContent(DependencyObject element)
{
return (object) element.GetValue(OnContentProperty);
}
///
/// Allows an on (IsChecked) template to be provided on supporting styles.
///
public static readonly DependencyProperty OnContentTemplateProperty = DependencyProperty.RegisterAttached(
"OnContentTemplate", typeof (DataTemplate), typeof (ToggleButtonAssist), new PropertyMetadata(default(DataTemplate)));
///
/// Allows an on (IsChecked) template to be provided on supporting styles.
///
public static void SetOnContentTemplate(DependencyObject element, DataTemplate value)
{
element.SetValue(OnContentTemplateProperty, value);
}
///
/// Allows an on (IsChecked) template to be provided on supporting styles.
///
public static DataTemplate GetOnContentTemplate(DependencyObject element)
{
return (DataTemplate) element.GetValue(OnContentTemplateProperty);
}
}
}