{"id":328066,"date":"2022-01-15T21:00:20","date_gmt":"2022-01-15T21:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328066"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328066","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u043b user-control \u043d\u0430 WPF (VS2019, c#)<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e &#8212; \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f =)<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0435\u043a\u0441\u0442\u043e\u043f\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 \u0432\u0438\u043d\u0434\u0443 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u043c \u0431\u044b\u043b\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043e \u0444\u0438 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043d\u043e\u043f\u043e\u043a. \u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0430-\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445. <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u043a\u043d\u043e\u043f\u043a\u0438 (WPF): \u043a\u0440\u0443\u0433\u043b\u0430\u044f, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043a\u043e\u043d\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Path, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e IsChecked, \u0438 \u0441\u043c\u0435\u043d\u043e\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u0441\u0445\u0435\u043c \u043f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438\/\u043d\u0430\u0436\u0430\u0442\u0438\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 (\u0438\u043a\u043e\u043d\u043a\u0438 \u0441\u0430\u043c\u043e-\u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435):<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"75\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0a3\/c11\/389\/0a3c11389da21c16f79e961838ef103b.png\" data-width=\"148\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b VectorRoundButton, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044f \u0435\u0433\u043e \u043e\u0442 UserControl. XAML \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0439 Grid; \u043e\u0431\u044a\u0435\u043a\u0442 Ellipse, \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0441\u0442\u043e\u043b\u044c \u0436\u0435\u043b\u0430\u043d\u043d\u0443\u044e \u043a\u0440\u0443\u0433\u043b\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 Path \u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0438\u043a\u043e\u043d\u043a\u043e\u0439.<\/p>\n<pre><code class=\"xml\">&lt;UserControl x:Class=\"UserControls.VectorRoundButton\"              xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"              xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"              xmlns:mc=\"http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006\"               xmlns:d=\"http:\/\/schemas.microsoft.com\/expression\/blend\/2008\"               xmlns:local=\"clr-namespace:UserControls\"               mc:Ignorable=\"d\"               d:DesignHeight=\"50\" d:DesignWidth=\"50\" Loaded=\"UserControl_Loaded\" MouseEnter=\"UserControl_MouseEnter\" MouseLeave=\"UserControl_MouseLeave\" MouseLeftButtonDown=\"UserControl_MouseLeftButtonDown\" MouseLeftButtonUp=\"UserControl_MouseLeftButtonUp\">     &lt;Grid>         &lt;Grid.RowDefinitions>             &lt;RowDefinition Height=\"20*\"\/>             &lt;RowDefinition Height=\"60*\"\/>             &lt;RowDefinition Height=\"20*\"\/>         &lt;\/Grid.RowDefinitions>         &lt;Grid.ColumnDefinitions>             &lt;ColumnDefinition Width=\"20*\"\/>             &lt;ColumnDefinition Width=\"60*\"\/>             &lt;ColumnDefinition Width=\"20*\"\/>         &lt;\/Grid.ColumnDefinitions>                &lt;Ellipse x:Name=\"ButtonEllipse\" Grid.ColumnSpan=\"3\" Grid.RowSpan=\"3\"\/>        &lt;Path x:Name=\"ButtonImage\" Stretch=\"Uniform\" Grid.Row=\"1\" Grid.Column=\"1\" \/>      &lt;\/Grid> &lt;\/UserControl> <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0432\u0438\u0434\u0430 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<p><strong>IsCheckable<\/strong> &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441\u0430 <br \/><strong>IsChecked<\/strong> &#8212; \u0432 \u0440\u0435\u0447\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441\u0430 &#8212; \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e (\u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0431\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0440\u0443\u0436\u043a\u043e\u043c)<br \/><strong>ActiveButtonColor<\/strong> &#8212; \u0446\u0432\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 (\u043f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u043e\u0440\u0435)<br \/><strong>InactiveButtonColor<\/strong> &#8212; \u0446\u0432\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438<br \/><strong>ButtonIcon<\/strong> &#8212; \u0438\u043a\u043e\u043d\u043a\u0430 \u043a\u043d\u043e\u043f\u043a\u0438<\/p>\n<pre><code class=\"cs\"> public partial class VectorRoundButton : UserControl     {         public bool IsCheckable         {             get { return (bool)GetValue(IsCheckableProperty); }             set { SetValue(IsCheckableProperty, value); }         }          public bool IsChecked         {             get { return (bool)GetValue(IsCheckedProperty); }             set { SetValue(IsCheckedProperty, value); }         }          public Brush ActiveButtonColor         {             get { return (Brush)GetValue(ActiveButtonColorProperty); }             set { SetValue(ActiveButtonColorProperty, value); }         }          public Brush InactiveButtonColor         {             get { return (Brush)GetValue(InactiveButtonColorProperty); }             set { SetValue(InactiveButtonColorProperty, value); }         }          public Path ButtonIcon         {             get { return (Path)GetValue(ButtonIconProperty); }             set { SetValue(ButtonIconProperty, value); }         }      }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0442\u043a\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <strong>DependencyProperty:<\/strong><\/p>\n<pre><code class=\"cs\">public static readonly DependencyProperty IsCheckableProperty = DependencyProperty.Register(   \"IsCheckable\",   typeof(bool),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCheckablePropertChanged));  public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(   \"IsChecked\",   typeof(bool),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCkeckedPropertChanged));  public static readonly DependencyProperty InactiveButtonColorProperty = DependencyProperty.Register(   \"InactiveButtonColor\",   typeof(Brush),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlBrush, FrameworkPropertyMetadataOptions.AffectsRender, InactiveButtonColorPropertyChanged));  public static readonly DependencyProperty ActiveButtonColorProperty = DependencyProperty.Register(   \"ActiveButtonColor\",   typeof(Brush),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlDarkBrush, FrameworkPropertyMetadataOptions.AffectsRender, ActiveButtonColorPropertyChanged));  public static readonly DependencyProperty ButtonIconProperty = DependencyProperty.Register(   \"ButtonIcon\",   typeof(Path),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, ButtonIconPropertyChanged));<\/code><\/pre>\n<p>\u0412 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0438\u043a\u043e\u043d\u043a\u0438, \u0446\u0432\u0435\u0442\u0430, \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0442.\u0434. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043a\u043e\u043d\u043a\u0438 \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<pre><code class=\"cs\">private static void ButtonIconPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.ButtonIcon.Data = (e.NewValue as Path)?.Data;     control.ButtonIcon.Fill = (e.NewValue as Path)?.Fill;     control.ButtonImage.Data = control.ButtonIcon.Data;     control.ButtonImage.Fill = control.ButtonIcon.Fill;   } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<pre><code class=\"cs\">private static void ActiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.ActiveButtonColor = (Brush)e.NewValue;   } }  private static void InactiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.InactiveButtonColor = (Brush)e.NewValue;     control.ButtonEllipse.Fill = (Brush)e.NewValue;   } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430:<\/p>\n<pre><code class=\"cs\">private static void IsCkeckedPropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     if (control.IsCheckable)     {       control.IsChecked = (bool)e.NewValue;       if (control.IsChecked)       {         control.ButtonEllipse.Stroke = System.Windows.SystemColors.ControlDarkBrush;         control.ButtonEllipse.StrokeThickness = 2;       }       else       {         control.ButtonEllipse.Stroke = null;         control.ButtonEllipse.StrokeThickness = 1;       }     }   } }  private static void IsCheckablePropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.IsCheckable = (bool)e.NewValue;   } }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043c\u044b\u0448\u043a\u0438 \u0447\u0435\u0440\u0435\u0437  \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043b\u0435\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b\u0448\u0438:<\/p>\n<pre><code class=\"cs\">private void UserControl_MouseEnter(object sender, MouseEventArgs e) {   ButtonEllipse.Fill = ActiveButtonColor; }  private void UserControl_MouseLeave(object sender, MouseEventArgs e) {   ButtonEllipse.Fill = InactiveButtonColor;   if (!IsChecked)     ButtonEllipse.Stroke = null; }  private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {   ButtonEllipse.Stroke = System.Windows.SystemColors.ActiveCaptionBrush; }  private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {   ButtonEllipse.Fill = ActiveButtonColor;   ButtonEllipse.Stroke = null;   if (IsCheckable)   {     IsChecked = !IsChecked;   } }<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0438\u043c\u0435\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430:<\/p>\n<pre><code class=\"cs\">public partial class VectorRoundButton : UserControl     {         public bool IsCheckable         {             get { return (bool)GetValue(IsCheckableProperty); }             set { SetValue(IsCheckableProperty, value); }         }          public bool IsChecked         {             get { return (bool)GetValue(IsCheckedProperty); }             set { SetValue(IsCheckedProperty, value); }         }          public Brush ActiveButtonColor         {             get { return (Brush)GetValue(ActiveButtonColorProperty); }             set { SetValue(ActiveButtonColorProperty, value); }         }          public Brush InactiveButtonColor         {             get { return (Brush)GetValue(InactiveButtonColorProperty); }             set { SetValue(InactiveButtonColorProperty, value); }         }          public Path ButtonIcon         {             get { return (Path)GetValue(ButtonIconProperty); }             set { SetValue(ButtonIconProperty, value); }         }          public static readonly DependencyProperty IsCheckableProperty = DependencyProperty.Register(             \"IsCheckable\",             typeof(bool),             typeof(VectorRoundButton),             new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCheckablePropertChanged));          public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(           \"IsChecked\",           typeof(bool),           typeof(VectorRoundButton),           new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCkeckedPropertChanged));          public static readonly DependencyProperty InactiveButtonColorProperty = DependencyProperty.Register(           \"InactiveButtonColor\",           typeof(Brush),           typeof(VectorRoundButton),           new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlBrush, FrameworkPropertyMetadataOptions.AffectsRender, InactiveButtonColorPropertyChanged));          public static readonly DependencyProperty ActiveButtonColorProperty = DependencyProperty.Register(          \"ActiveButtonColor\",          typeof(Brush),          typeof(VectorRoundButton),          new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlDarkBrush, FrameworkPropertyMetadataOptions.AffectsRender, ActiveButtonColorPropertyChanged));          public static readonly DependencyProperty ButtonIconProperty = DependencyProperty.Register(             \"ButtonIcon\",             typeof(Path),             typeof(VectorRoundButton),             new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, ButtonIconPropertyChanged));           private static void ButtonIconPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)         {             if (source is VectorRoundButton)             {                 VectorRoundButton control = source as VectorRoundButton;                 control.ButtonIcon.Data = (e.NewValue as Path)?.Data;                 control.ButtonIcon.Fill = (e.NewValue as Path)?.Fill;                 control.ButtonImage.Data = control.ButtonIcon.Data;                 control.ButtonImage.Fill = control.ButtonIcon.Fill;             }         }          private static void ActiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)         {             if (source is VectorRoundButton)             {                 VectorRoundButton control = source as VectorRoundButton;                 control.ActiveButtonColor = (Brush)e.NewValue;             }         }          private static void InactiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)         {             if (source is VectorRoundButton)             {                 VectorRoundButton control = source as VectorRoundButton;                 control.InactiveButtonColor = (Brush)e.NewValue;                 control.ButtonEllipse.Fill = (Brush)e.NewValue;             }         }          private static void IsCkeckedPropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)         {             if (source is VectorRoundButton)             {                 VectorRoundButton control = source as VectorRoundButton;                 if (control.IsCheckable)                 {                     control.IsChecked = (bool)e.NewValue;                                          if (control.IsChecked)                     {                         control.ButtonEllipse.Stroke = System.Windows.SystemColors.ControlDarkBrush;                         control.ButtonEllipse.StrokeThickness = 2;                     }                     else                     {                         control.ButtonEllipse.Stroke = null;                         control.ButtonEllipse.StrokeThickness = 1;                     }                 }             }         }          private static void IsCheckablePropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)         {             if (source is VectorRoundButton)             {                 VectorRoundButton control = source as VectorRoundButton;                 control.IsCheckable = (bool)e.NewValue;             }         }          public VectorRoundButton()         {             InitializeComponent();         }          private void UserControl_Loaded(object sender, RoutedEventArgs e)         {             ButtonImage.Fill = ButtonIcon?.Fill;             ButtonImage.Data = ButtonIcon?.Data;             ButtonEllipse.Fill = InactiveButtonColor;         }          private void UserControl_MouseEnter(object sender, MouseEventArgs e)         {             ButtonEllipse.Fill = ActiveButtonColor;         }          private void UserControl_MouseLeave(object sender, MouseEventArgs e)         {             ButtonEllipse.Fill = InactiveButtonColor;             if (!IsChecked)                 ButtonEllipse.Stroke = null;         }          private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)         {             ButtonEllipse.Stroke = System.Windows.SystemColors.ActiveCaptionBrush;         }          private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)         {             ButtonEllipse.Fill = ActiveButtonColor;             ButtonEllipse.Stroke = null;             if (IsCheckable)             {                 IsChecked = !IsChecked;             }         }     }<\/code><\/pre>\n<p>\u0412\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0432\u0441\u0435 =) \u041f\u043e\u043d\u0438\u043c\u0430\u044e, \u0447\u0442\u043e \u0432\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0434\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0434\u043b\u044f \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043a\u0440\u0438\u0432\u0430\u044f, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0443\u0447\u0435\u0431\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443 \u0438 \u0441\u0433\u043e\u0434\u0438\u0442\u0441\u044f. <\/p>\n<p>\u041a\u0430\u043c\u043d\u044f\u043c\u0438 \u043d\u0435 \u043a\u0438\u0434\u0430\u0439\u0442\u0435\u0441\u044c, \u0437\u0430 \u0441\u0438\u043c \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u043a\u043b\u0430\u043d\u044f\u0442\u044c\u0441\u044f =)<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/645791\/\"> https:\/\/habr.com\/ru\/post\/645791\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u0441\u0435\u0445 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e, \u0440\u0435\u0448\u0438\u043b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0441\u0442 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e &#8212; \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u0430 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f =)<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0435\u043a\u0441\u0442\u043e\u043f\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u0434 \u0432\u0438\u043d\u0434\u0443 \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u043e\u043c \u0431\u044b\u043b\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043e \u0444\u0438 \u043f\u043e \u043f\u043e\u0432\u043e\u0434\u0443 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u043a\u043d\u043e\u043f\u043e\u043a. \u0412\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u0430-\u043b\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445. <\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430: \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b \u043a\u043d\u043e\u043f\u043a\u0438 (WPF): \u043a\u0440\u0443\u0433\u043b\u0430\u044f, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u043a\u043e\u043d\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Path, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e IsChecked, \u0438 \u0441\u043c\u0435\u043d\u043e\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u0441\u0445\u0435\u043c \u043f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438\/\u043d\u0430\u0436\u0430\u0442\u0438\u0438.<\/p>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435 \u043a\u043d\u043e\u043f\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 (\u0438\u043a\u043e\u043d\u043a\u0438 \u0441\u0430\u043c\u043e-\u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435):<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b VectorRoundButton, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044f \u0435\u0433\u043e \u043e\u0442 UserControl. XAML \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430: \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0439 Grid; \u043e\u0431\u044a\u0435\u043a\u0442 Ellipse, \u0441\u0438\u043c\u0432\u043e\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0441\u0442\u043e\u043b\u044c \u0436\u0435\u043b\u0430\u043d\u043d\u0443\u044e \u043a\u0440\u0443\u0433\u043b\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442 Path \u0441 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0438\u043a\u043e\u043d\u043a\u043e\u0439.<\/p>\n<pre><code class=\"xml\">&lt;UserControl x:Class=\"UserControls.VectorRoundButton\"              xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"              xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"              xmlns:mc=\"http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006\"               xmlns:d=\"http:\/\/schemas.microsoft.com\/expression\/blend\/2008\"               xmlns:local=\"clr-namespace:UserControls\"               mc:Ignorable=\"d\"               d:DesignHeight=\"50\" d:DesignWidth=\"50\" Loaded=\"UserControl_Loaded\" MouseEnter=\"UserControl_MouseEnter\" MouseLeave=\"UserControl_MouseLeave\" MouseLeftButtonDown=\"UserControl_MouseLeftButtonDown\" MouseLeftButtonUp=\"UserControl_MouseLeftButtonUp\">     &lt;Grid>         &lt;Grid.RowDefinitions>             &lt;RowDefinition Height=\"20*\"\/>             &lt;RowDefinition Height=\"60*\"\/>             &lt;RowDefinition Height=\"20*\"\/>         &lt;\/Grid.RowDefinitions>         &lt;Grid.ColumnDefinitions>             &lt;ColumnDefinition Width=\"20*\"\/>             &lt;ColumnDefinition Width=\"60*\"\/>             &lt;ColumnDefinition Width=\"20*\"\/>         &lt;\/Grid.ColumnDefinitions>                &lt;Ellipse x:Name=\"ButtonEllipse\" Grid.ColumnSpan=\"3\" Grid.RowSpan=\"3\"\/>        &lt;Path x:Name=\"ButtonImage\" Stretch=\"Uniform\" Grid.Row=\"1\" Grid.Column=\"1\" \/>      &lt;\/Grid> &lt;\/UserControl> <\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0432\u0438\u0434\u0430 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<p><strong>IsCheckable<\/strong> &#8212; \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441\u0430 <br \/><strong>IsChecked<\/strong> &#8212; \u0432 \u0440\u0435\u0447\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441\u0430 &#8212; \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e (\u043a\u043d\u043e\u043f\u043a\u0430 \u043e\u0431\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a\u0440\u0443\u0436\u043a\u043e\u043c)<br \/><strong>ActiveButtonColor<\/strong> &#8212; \u0446\u0432\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 (\u043f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u043a\u0443\u0440\u0441\u043e\u0440\u0435)<br \/><strong>InactiveButtonColor<\/strong> &#8212; \u0446\u0432\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438<br \/><strong>ButtonIcon<\/strong> &#8212; \u0438\u043a\u043e\u043d\u043a\u0430 \u043a\u043d\u043e\u043f\u043a\u0438<\/p>\n<pre><code class=\"cs\"> public partial class VectorRoundButton : UserControl     {         public bool IsCheckable         {             get { return (bool)GetValue(IsCheckableProperty); }             set { SetValue(IsCheckableProperty, value); }         }          public bool IsChecked         {             get { return (bool)GetValue(IsCheckedProperty); }             set { SetValue(IsCheckedProperty, value); }         }          public Brush ActiveButtonColor         {             get { return (Brush)GetValue(ActiveButtonColorProperty); }             set { SetValue(ActiveButtonColorProperty, value); }         }          public Brush InactiveButtonColor         {             get { return (Brush)GetValue(InactiveButtonColorProperty); }             set { SetValue(InactiveButtonColorProperty, value); }         }          public Path ButtonIcon         {             get { return (Path)GetValue(ButtonIconProperty); }             set { SetValue(ButtonIconProperty, value); }         }      }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0442\u043a\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 <strong>DependencyProperty:<\/strong><\/p>\n<pre><code class=\"cs\">public static readonly DependencyProperty IsCheckableProperty = DependencyProperty.Register(   \"IsCheckable\",   typeof(bool),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCheckablePropertChanged));  public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(   \"IsChecked\",   typeof(bool),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCkeckedPropertChanged));  public static readonly DependencyProperty InactiveButtonColorProperty = DependencyProperty.Register(   \"InactiveButtonColor\",   typeof(Brush),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlBrush, FrameworkPropertyMetadataOptions.AffectsRender, InactiveButtonColorPropertyChanged));  public static readonly DependencyProperty ActiveButtonColorProperty = DependencyProperty.Register(   \"ActiveButtonColor\",   typeof(Brush),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(System.Windows.SystemColors.ControlDarkBrush, FrameworkPropertyMetadataOptions.AffectsRender, ActiveButtonColorPropertyChanged));  public static readonly DependencyProperty ButtonIconProperty = DependencyProperty.Register(   \"ButtonIcon\",   typeof(Path),   typeof(VectorRoundButton),   new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender, ButtonIconPropertyChanged));<\/code><\/pre>\n<p>\u0412 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u0445 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u0438\u043a\u043e\u043d\u043a\u0438, \u0446\u0432\u0435\u0442\u0430, \u043d\u0430\u0436\u0430\u0442\u0438\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u0442.\u0434. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438.<\/p>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043a\u043e\u043d\u043a\u0438 \u043d\u0430\u0448\u0435\u0439 \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<pre><code class=\"cs\">private static void ButtonIconPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.ButtonIcon.Data = (e.NewValue as Path)?.Data;     control.ButtonIcon.Fill = (e.NewValue as Path)?.Fill;     control.ButtonImage.Data = control.ButtonIcon.Data;     control.ButtonImage.Fill = control.ButtonIcon.Fill;   } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u0432 \u043a\u043d\u043e\u043f\u043a\u0438:<\/p>\n<pre><code class=\"cs\">private static void ActiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.ActiveButtonColor = (Brush)e.NewValue;   } }  private static void InactiveButtonColorPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.InactiveButtonColor = (Brush)e.NewValue;     control.ButtonEllipse.Fill = (Brush)e.NewValue;   } }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0434\u043b\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0447\u0435\u043a-\u0431\u043e\u043a\u0441, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\/\u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u0436\u0438\u043c\u0430:<\/p>\n<pre><code class=\"cs\">private static void IsCkeckedPropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     if (control.IsCheckable)     {       control.IsChecked = (bool)e.NewValue;       if (control.IsChecked)       {         control.ButtonEllipse.Stroke = System.Windows.SystemColors.ControlDarkBrush;         control.ButtonEllipse.StrokeThickness = 2;       }       else       {         control.ButtonEllipse.Stroke = null;         control.ButtonEllipse.StrokeThickness = 1;       }     }   } }  private static void IsCheckablePropertChanged(DependencyObject source, DependencyPropertyChangedEventArgs e) {   if (source is VectorRoundButton)   {     VectorRoundButton control = source as VectorRoundButton;     control.IsCheckable = (bool)e.NewValue;   } }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e &#8212; \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043a\u0446\u0438\u044e \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043c\u044b\u0448\u043a\u0438 \u0447\u0435\u0440\u0435\u0437  \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043b\u0435\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u0438 \u043c\u044b\u0448\u0438:<\/p>\n<pre><code class=\"cs\">private void UserControl_MouseEnter(object sender, MouseEventArgs e) {   ButtonEllipse.Fill = ActiveButtonColor; }  private void UserControl_MouseLeave(object sender, MouseEventArgs e) {   ButtonEllipse.Fill = InactiveButtonColor;   if (!IsChecked)     ButtonEllipse.Stroke = null; }  private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {   ButtonEllipse.Stroke = System.Windows.SystemColors.ActiveCaptionBrush; }  private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {   ButtonEllipse.Fill = ActiveButtonColor;   ButtonEllipse.Stroke = null;   if (IsCheckable)   {     IsChecked = !IsChecked;   } }<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u0435, \u0438\u043c\u0435\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0430:<\/p>\n<pre><code class=\"cs\">public partial class VectorRoundButton : UserControl     {         public bool IsCheckable         {             get { return (bool)GetValue(IsCheckableProperty); }             set { SetValue(IsCheckableProperty, value); }         }          public bool IsChecked         {             get { return (bool)GetValue(IsCheckedProperty); }             set { SetValue(IsCheckedProperty, value); }         }          public Brush ActiveButtonColor         {             get { return (Brush)GetValue(ActiveButtonColorProperty); }             set { SetValue(ActiveButtonColorProperty, value); }         }          public Brush InactiveButtonColor         {             get { return (Brush)GetValue(InactiveButtonColorProperty); }             set { SetValue(InactiveButtonColorProperty, value); }         }          public Path ButtonIcon         {             get { return (Path)GetValue(ButtonIconProperty); }             set { SetValue(ButtonIconProperty, value); }         }          public static readonly DependencyProperty IsCheckableProperty = DependencyProperty.Register(             \"IsCheckable\",             typeof(bool),             typeof(VectorRoundButton),             new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCheckablePropertChanged));          public static readonly DependencyProperty IsCheckedProperty = DependencyProperty.Register(           \"IsChecked\",           typeof(bool),           typeof(VectorRoundButton),           new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender, IsCkeckedPropertChanged));          public static readonly DependencyProperty<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328066","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=328066"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328066\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}