How to inherit Button behaviour in WPF style?

前端 未结 3 1018
清歌不尽
清歌不尽 2021-01-21 01:13

I have overriden the WPF default Maximize, Minimize buttons like explained here. But, in my case, instead of using an Image to override background image for that bu

3条回答
  •  隐瞒了意图╮
    2021-01-21 01:34

    There is not much to inherit. I suggest you write simple handlers and assign them for button click events. Handlers can be as follows:

        protected void MinimizeClick(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }
        protected void MaximizeClick(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Maximized ;
        }
    
        protected void RestoreClick(object sender, RoutedEventArgs e)
        {
            WindowState = (WindowState == WindowState.Normal) ? WindowState.Maximized :     WindowState.Normal;
        }
    
        protected void CloseClick(object sender, RoutedEventArgs e)
        {
            Close();
        }
    

提交回复
热议问题