Breaking News
Loading...
Friday 26 April 2013

How to use border with shadow in wpf

Steps:

1)  First create two window form
2)  Nn patent form add one button



3)  Now add border with shadow in this windown

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="400" Width="1000">
    <Grid>
        <Button Content="Click to show demo" Height="23" HorizontalAlignment="Left" Margin="318,203,0,0" Name="button1" VerticalAlignment="Top" Width="140" Click="button1_Click" />

        <Border x:Name="shadow"
            Grid.ColumnSpan="3"
            Grid.RowSpan="2"
            Background="black"
            Opacity="0.36"
            Visibility="Collapsed" Loaded="shadow_Loaded" ClipToBounds="False">
        </Border>


    </Grid>
   
</Window>

4) Now add second windown to this solution.


4)  now on butn click event add following code. first make object of second windownand set some propeties

private void button1_Click(object sender, RoutedEventArgs e)
{
            win2 objwin2 = new win2();
            DoubleAnimation animm = new DoubleAnimation();
            animm.From = 0;
            animm.To = 1;
            animm.Duration = new Duration(TimeSpan.FromSeconds(0.3));
            objwin2.BeginAnimation(UIElement.OpacityProperty, animm);
            shadow.Visibility = Visibility.Visible;
            objwin2.ShowDialog();
            shadow.Visibility = Visibility.Collapsed;

}

0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer