Wednesday, April 9, 2014

Creating the Pop up in WPF

Write this code in Window.xaml file....

<Window x:Class="WpfApplication1.Window2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window2" Height="300" Width="300">
    <Grid>
        <TextBlock TextWrapping="Wrap">You can use a Popup to provide a link for a specific <Run TextDecorations="Underline" MouseEnter="run_MouseEnter">term</Run> of interest.</TextBlock>

        <Popup Name="popLink" StaysOpen="False" Placement="Mouse" MaxWidth="200" PopupAnimation="Fade"  AllowsTransparency="True">
            <Border BorderBrush="Beige" BorderThickness="2" Background="White">
                <TextBlock Margin="10" TextWrapping="Wrap">      For more information, see      <Hyperlink NavigateUri="https://plus.google.com/u/0/+HimanshuGautam1990/about" Click="lnk_Click">here</Hyperlink></TextBlock>
            </Border>
        </Popup>
    </Grid>
</Window>


       

           
                          
           
       
         
       


And write this code in Window.xaml.cs file...

      private void run_MouseEnter(object sender, MouseEventArgs e)
        {
            popLink.IsOpen = true;
        }
        private void lnk_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Process.Start(((Hyperlink)sender).NavigateUri.ToString());
        }

No comments:

Post a Comment