1

I am newbie in WPF and C#, but I started to develope a WPF NavigationWindow application. I want it to be chromeless window with custom maximize/minimize controls. But when I set events for my buttons, they don't affect the window.

Here's my XAML:

<NavigationWindow x:Class="app.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="app title" Height="600" Width="800" MinHeight="600" MinWidth="800" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Icon="appIcon.ico" Source="starting.xaml">
</NavigationWindow>

here is my click event for the button:

private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MainWindow window = new MainWindow();
            window.WindowState = WindowState.Minimized;
        }

Forgive me, if I am duplicating question, and also keep in mind, that I am new in this kind of programming :) so help, please

David B
  • 2,688
  • 18
  • 25
crazyname
  • 135
  • 1
  • 15

1 Answers1

1

Don't make a new window, try using the one you are using.

Try this:

// MainWindow window = new MainWindow();
this.WindowState = WindowState.Minimized;
LarsTech
  • 80,625
  • 14
  • 153
  • 225
  • Thanks for your reply. But I fire the event within a page. When I try with this.WindowState = WindowState.minimized; ... I get the following error: app.Page does not contain a definition for 'WindowState' and no extension method 'WindowState' accepting a first argument of type app.Page could be found (are you missing a using directive or an assembly reference?) is there a way to add the buttons to the MainWindow, and am I missing something? :/ – crazyname Jul 27 '12 at 14:46
  • 2
    ahhhhhhh solved !! :))) Window window = Window.GetWindow(this); window.WindowState = WindowState.Minimized; – crazyname Jul 27 '12 at 14:48