76 lines
2.1 KiB
C#
76 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices.WindowsRuntime;
|
|
using Windows.Foundation;
|
|
using Windows.Foundation.Collections;
|
|
using Windows.UI.Xaml;
|
|
using Windows.UI.Xaml.Controls;
|
|
using Windows.UI.Xaml.Controls.Primitives;
|
|
using Windows.UI.Xaml.Data;
|
|
using Windows.UI.Xaml.Input;
|
|
using Windows.UI.Xaml.Media;
|
|
using Windows.UI.Xaml.Navigation;
|
|
|
|
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
|
|
|
namespace AutoCat.Controls
|
|
{
|
|
public sealed partial class ButtonCell : UserControl
|
|
{
|
|
#region Dependency properties
|
|
|
|
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnTitleChanged));
|
|
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnValueChanged));
|
|
public static readonly DependencyProperty DefaultValueProperty = DependencyProperty.Register("Title", typeof(string), typeof(TextCell), new PropertyMetadata(null, OnValueChanged));
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public string Title
|
|
{
|
|
get => (string)GetValue(TitleProperty);
|
|
set => SetValue(TitleProperty, value);
|
|
}
|
|
|
|
public string Value
|
|
{
|
|
get => (string)GetValue(ValueProperty);
|
|
set => SetValue(ValueProperty, value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
public ButtonCell()
|
|
{
|
|
this.InitializeComponent();
|
|
}
|
|
|
|
private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (d is ButtonCell cell && e.NewValue is string title)
|
|
{
|
|
cell.TitleBox.Text = title ?? "";
|
|
}
|
|
}
|
|
|
|
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (d is ButtonCell cell && e.NewValue is string value)
|
|
{
|
|
cell.ValueButton.Content = value ?? "";
|
|
}
|
|
}
|
|
|
|
private static void OnDefaultValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (d is ButtonCell cell && e.NewValue is string value)
|
|
{
|
|
cell.ValueButton.Content = value ?? "";
|
|
}
|
|
}
|
|
}
|
|
}
|