Click here to Skip to main content
15,907,149 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I tried to make a metro Style popup for my application i.e. in WPF. For rest of the user i tried this.Just for Other coder out there. But how to make open like showdialog??

XML
<Grid>
      <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition/>
      </Grid.RowDefinitions>
      <StackPanel Name="SP" Orientation="Horizontal" Background="Black">
          <TextBox x:Name="txtSearch" Width="100" Margin="2,2,10,2" Text="msdn pejl"/>
          <Button Width="100" Content="Go!" Margin="2" Click="Button_Click" />
      </StackPanel>

      <Popup x:Name="ProfilePopup"  Height="Auto" Width="{Binding ActualWidth, ElementName=SP}" Placement="Center" >
          <StackPanel Background="SteelBlue">
              <StackPanel HorizontalAlignment="Center"  >
              <Grid Background="SteelBlue">
                  <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="100" />
                      <ColumnDefinition Width="100" />
                      <ColumnDefinition Width="150" />
                      <ColumnDefinition Width="50" />
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                      <RowDefinition />
                      <RowDefinition />
                      <RowDefinition />
                      <RowDefinition />
                  </Grid.RowDefinitions>

                  <Label Grid.Column="0" Foreground="White" Grid.Row="0" Grid.ColumnSpan="3" FontSize="18" Margin="10">Please Login To Access This Application</Label>
                  <Label Grid.Column="1" Foreground="White" Grid.Row="1">User Name</Label>
                  <TextBox Grid.Column="2" Foreground="Black" Background="White" Grid.Row="1" ToolTip="Enter Your User Name" Name="txtUserName" />
                  <Label Grid.Column="1" Foreground="White" Grid.Row="2">Password</Label>
                  <PasswordBox Grid.Column="2" Grid.Row="2" ToolTip="Enter Your Password" Name="txtPassword" />


                  <StackPanel Grid.Column="2" Grid.Row="3" Margin="10" HorizontalAlignment="Center" Orientation="Horizontal">

                      <Button Name="btnCancel" IsCancel="True" Content="Cancel" Click="btnCancel_Click" />
                      <Button Name="btnLogin" IsDefault="True" Content="Login" Click="btnLogin_Click" />


                  </StackPanel>
              </Grid>
          </StackPanel>
              </StackPanel>
      </Popup>

  </Grid>
Posted
Updated 11-Jan-15 19:21pm
v2
Comments
LLLLGGGG 11-Jan-15 15:57pm    
Thanks, but I think it's the wrong place to submit this kind of code if you have not any questions about it...
You, instead, should post it under articles or tips and explain it just a little bit more :), because this section is only for questions and not for posting code which has no problems.
The fact is that anyone would look for this type of helps in the Q&A section, but in the articles/tips one.

Hope this helped.

LG
aksjustcool 12-Jan-15 1:23am    
Hi Jymmy097, thanx for your input will remember this. I have just updated my question. Kindly share your input for this Thanx

1 solution

Hi,

to do that, you have to use another Window and maybe create a new usercontrol to store your WPF code...

The window has to have the WindowStyle set to none in order to hide the three default buttons in WpF windows and WindowStartupLocation set to CenterOwner. (I'm sorry, but I cannot remember the exact name of the property right now, but the names are really similar to the ones I have written)
Then, inside another window, instantiate your window and call the method ShowDialog.

For more information about dialogs in WpF, see WPF dialog Windows in msdn or google... you'll find a lot of useful information.

Hope this helps

LG
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900