Answered Make backgroud blur when a dialogbox appear

  • Saturday, August 18, 2012 11:31 AM
     
     

    I want background to be blur whenever a messagebox (or any dialogbox) appear and disappear as soon as main window is returned. How can I do this?

All Replies

  • Saturday, August 18, 2012 3:03 PM
     
     Proposed

    Display the content of the messagebox with Popup when you open it, it automatically blackout the background area, till you close the popup....

    ___________________________________________________________

    Do vote the answer and propose the answer

    • Proposed As Answer by kishhr Saturday, August 18, 2012 3:03 PM
    •  
  • Saturday, August 18, 2012 3:31 PM
     
     Answered Has Code

    Use a Blur effect on the window, perhaps create an animation that changes the Blurs Radius value

    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:System="clr-namespace:System;assembly=mscorlib"
    	x:Class="MainWindow"
    	x:Name="Window"
    	Title="MainWindow"
    	Width="640" Height="480">
    	<Window.Resources>
    		<Storyboard x:Key="BlurWindow">
    			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(BlurEffect.Radius)" Storyboard.TargetName="Window">
    				<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
    				<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="5"/>
    			</DoubleAnimationUsingKeyFrames>
    		</Storyboard>
    	</Window.Resources>
    	<Window.Triggers>
    		<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="button">
    			<BeginStoryboard Storyboard="{StaticResource BlurWindow}"/>
    		</EventTrigger>
    	</Window.Triggers>
        <Window.Effect>
            <BlurEffect Radius="0"/>
        </Window.Effect>
        <Grid x:Name="LayoutRoot">
    		<Grid.ColumnDefinitions>
    			<ColumnDefinition Width="0.24*"/>
    			<ColumnDefinition Width="0.393*"/>
    			<ColumnDefinition Width="0.367*"/>
    		</Grid.ColumnDefinitions>
    		<Button x:Name="button" Content="Button" Width="75" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    		<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" Grid.Column="1"><Run Text="TextBlock"/></TextBlock>
    		<ListBox Height="100" VerticalAlignment="Center" Margin="0,0,50,0" Grid.Column="2" HorizontalAlignment="Center">
    			<ListBoxItem Content="One"/>
    			<ListBoxItem Content="Two"/>
    			<ListBoxItem Content="Three"/>
    		</ListBox>
    	</Grid>
    </Window>