积极答复者
wpf 使用popup模拟模态对话框闪烁效果

问题
-
<Page x:Class="WpfModalDialog.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainPage"> <StackPanel x:Name="MainPanel"> <Grid> <Button Height="28" Margin="0,30,0,0" Name="BtnShowDlg" VerticalAlignment="Top" HorizontalAlignment="Center" Click="BtnShowDlg_Click">Show Modal Dialog</Button> <Label Height="28" Margin="0,68,0,0" Width="360" Name="labelString" VerticalAlignment="Top" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="1" BorderBrush="DarkBlue">Click the above button</Label> </Grid> <Popup Name="ModalDialog" StaysOpen="True" Placement="Center"> <Border BorderThickness="2" BorderBrush="SteelBlue" Width="400" Height="130"> <Grid Background="White"> <DockPanel Height="28" VerticalAlignment="Top" Background="SteelBlue"> <TextBox Height="26" Name="TxtBoxTitle" Width="120" Background="SteelBlue" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="White" FontSize="16" Focusable="False" IsHitTestVisible="False" IsTabStop="False" VerticalContentAlignment="Center">WPF Modal Dialog</TextBox> <Button Height="26" Name="BtnClose" Width="26" HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="16" Background="SteelBlue" Click="Dlg_BtnClose_Click">X</Button> </DockPanel> <Grid Margin="0,30,0,0"> <Label Margin="15,0,0,0" Height="28" VerticalAlignment="Top" HorizontalAlignment="Left" VerticalContentAlignment="Center" >Input a string: </Label> <TextBox Height="28" Name="TxtBoxInput" Width="360" HorizontalAlignment="Center" VerticalContentAlignment="Center"/> <Button Margin="0,60,100,0" Height="22" Width="68" HorizontalAlignment="Right" Click="Dlg_BtnOK_Click">OK</Button> <Button Margin="0,60,15,0" Height="22" Width="68" HorizontalAlignment="Right" Click="Dlg_BtnClose_Click">Cancel</Button> </Grid> </Grid> </Border> </Popup> </StackPanel> </Page>
使用的是以上popup来模拟模态对话框,如何实现点击非popup窗体区域时,popup高亮闪烁效果,即实现MessageBox.Show()点击非MessageBox区域时MessageBox高亮闪烁。
原先使用的var window = new Window();
window.Owner = this;
window.ShowDialog();来实现的弹出窗体效果,后发现该方法会多1个进程,故放弃.Ths
答案
-
暂时没有找到好的办法,采用了telerik的RadWindow作为弹出框架.
原先是想实现一个弹出窗口类似于MessageBox的模态效果,如点击MessageBox外面是,程序整个窗口会高亮显示等。具体效果可以自己写个demo弹出个MessageBox,看下。
- 已标记为答案 Jason Dot WangModerator 2013年12月6日 9:35