Create Round Button with Border IN UWP Windows 10 C#

后端 未结 6 1260
盖世英雄少女心
盖世英雄少女心 2021-02-07 16:47

I am trying to create a round button, with a White Border and a Transparent Background (as the old AppBarButtons in Windows 8.1) in UWP Windows 10.

I have found several

6条回答
  •  情书的邮戳
    2021-02-07 16:53

    Another sample

    
    

    Result

    Or Create fully customizable cornerradius

    //Create a template control xaml design

    
    
    

    //Template control.cs

    public sealed class CustomRoundedButton : Button
    {
        private Grid _rootGrid = null;
        public CustomRoundedButton()
        {
            this.DefaultStyleKey = typeof(CustomRoundedButton);
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
            _rootGrid = GetTemplateChild("RootGrid") as Grid;
        }
        public CornerRadius CornerRadius
        {
            get { return (CornerRadius)GetValue(CornerRadiusProperty); }
            set { SetValue(CornerRadiusProperty, value); }
        }
        public static readonly DependencyProperty CornerRadiusProperty =
            DependencyProperty.Register("CornerRadius", typeof(CornerRadius), typeof(CustomRoundedButton), new PropertyMetadata(new CornerRadius(10,10,10,10)));
    
    }
    

    //Register to or merge dictionary from /Themes/Generic.xaml

    
        
          
    

提交回复
热议问题