0

I have a WPF class library (with a user control within it being my launch page (similar to MainWindow).

Code Snippet for User control is as follows:

<UserControl x:Class="ABC" ...... >
    <Grid>
        <Label>Hello World</Label>
    </Grid>
</UserControl>

I created another WPF app (labelled Launcher) which would essentially call the this class library.

That project doesnt have any MainWindow (removed it) and am launching the User Control from App.xaml

<Application 
x:Class="Launcher.App" 
......
StartupUri="pack://application:,,,/Project;component/View/HelloWorld.xaml">

The app doesnt start in full screen ever and always need to maxime it on launching.

I know the answer should be in lines of removing the StartupUri from App.xaml and putting the App.xaml.cs

 private void Application_Startup(object sender, StartupEventArgs e)
 {
     //What to put here
 }

Since there is no MainWindow hence there is I cant do this:

  MainWindow wnd = new MainWindow();
  wnd.Title = "Something else";
  //Set StartupMode = "Maximized"
  wnd.Show();
Patrick
  • 864
  • 1
  • 14
  • 27

1 Answers1

1

Do you know the Size of your Screen , if so

    WindowStyle="None"
    WindowStartupLocation="Manual"
    Top="0" Left="0"
    ResizeMode="NoResize" 
    BorderThickness="0" 
    Height="1080" Width="1920"

If you need to figure it out in code behind

    WindowStyle="None"
    WindowStartupLocation="Manual"
    Top="0" Left="0"
    ResizeMode="NoResize" 
    BorderThickness="0" 
    Height="{Binding Height}" Width="{Binding Width}"

In order to get the size look here : The First Answer

Community
  • 1
  • 1
eran otzap
  • 12,293
  • 20
  • 84
  • 139
  • Eran - I do not know the size of the screen (and can get those with the link you sent). But my question is more to do with there is no Window to work with. In the example code u mentioned below - those properties are being set for user control? – Patrick Jun 25 '14 at 17:46
  • @Patrick OK I think I understand , how do you show that user control ? add that code to your question . – eran otzap Jun 26 '14 at 06:46
  • Eran - The user control is shown directly from the app. For now - since I wasnt moving forward - I called the MainWindow from Launcher app and in there then call the user control. That way I have access to all window properties. Not an ideal solution but this workaround is temporarily. – Patrick Jun 28 '14 at 23:25
  • Ok i think i get it , your Startup URI is a user control , and it is never full screen , see edit in my answer – eran otzap Jun 29 '14 at 01:23
  • Thanks Eran for all the help. I had forgotten to type app.xaml but my code posted from day 1 had it. Anyways as you have suggested (and I have previously written) - I now launch the user control from main window and have full access to main window properties – Patrick Jun 29 '14 at 04:43