Create one Static Variable Name as IsAppStartCall in your GUI A.
static bool IsAppStartCall = true;
2.Create Parameterised constructor for GUI A and in that check IsAppStartCall or not.
public void GUIA(bool isAppStartCall)
{
IsAppStartCall = isAppStartCall;
// do your other tasks here
}
3.Now in your Window Loaded event check above code like this
//in loaded event last statement should be like this.
//this will ensure that whenever AppstartCall=true is there then and then it will set this window to mimimise otherwise not.
if(IsAppStartCall)
{
this.WindowState=WindowState.Minimized;
IsAppStartCall= false; //as once we achieved this functionality we will set it to false
}
Find Solution that worked me
GUIA.xaml
<Window x:Class="WpfApplication1.GUIA"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button x:Name="btnCloseAnotherWindow" Click="btnCloseAnotherWindow_Click" Content="Click Me" Width="100" Height="100"/>
</Grid>
</Window>
GUIA.xaml.cs
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class GUIA : Window
{
static bool IsAppStart = true;
public GUIA()
{
InitializeComponent();
this.Loaded += GUIA_Loaded;
}
public GUIA(bool isAppStart)
{
IsAppStart = isAppStart;
this.Loaded += GUIA_Loaded;
}
void GUIA_Loaded(object sender, RoutedEventArgs e)
{
if (IsAppStart)
{
this.WindowState = System.Windows.WindowState.Minimized;
}
}
private void btnCloseAnotherWindow_Click(object sender, RoutedEventArgs e)
{
GUIA obj = new GUIA(false);
obj.Show();
}
}
}