1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace SampleProblem
{
/// <summary>
/// Logique d'interaction pour UserControl2.xaml
/// </summary>
public partial class MyControl : UserControl
{
public MyControl()
{
InitializeComponent();
}
private void CM_MODE_Click(object sender, RoutedEventArgs e)
{
this.IsValid = !this.IsValid;
}
public bool IsValid
{
get { return (bool)GetValue(IsValidProperty); }
set { SetValue(IsValidProperty, value); }
}
// Using a DependencyProperty as the backing store for IsValid. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsValidProperty =
DependencyProperty.Register("IsValid",
typeof(bool),
typeof(MyControl ),
new FrameworkPropertyMetadata(false,
FrameworkPropertyMetadataOptions.AffectsRender));
public Brush BrushGrid
{
get { return (Brush)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
// Using a DependencyProperty as the backing store for Foreground. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("BrushGrid",
typeof(Brush),
typeof(MyControl),
new FrameworkPropertyMetadata(Brushes.WhiteSmoke,
FrameworkPropertyMetadataOptions.AffectsRender));
}
} |
Partager