Connecting Tech Pros Worldwide Help | Site Map

WPF Popup problem

Newbie
 
Join Date: Jun 2007
Posts: 17
#1: Dec 2 '08
I have a little problem in a XAML application. When I use a popup in a
WPF application, I am not able to get rid of the popup from the view
even if I do Alt-Tab to move focus to other applications.

Even I have set stayopen=false

Following is the code which I have done.
Expand|Select|Wrap|Line Numbers
  1.  <!-- Middle Product List --> 
  2.         <GroupBox Grid.Column="1" Grid.Row="2"> 
  3.             <ScrollViewer VerticalScrollBarVisibility="Disabled"  HorizontalScrollBarVisibility="Disabled"> 
  4.                 <ListBox Style="{DynamicResource PhotoListBoxStyle}"  
  5.                 Name ="PhotoListBox"  
  6.                 Margin="5"  
  7.                 SelectionMode="Single"  
  8.                 ItemsSource="{Binding}"  
  9.                 HorizontalAlignment="Center"  
  10.                 VerticalAlignment="Center"  
  11.                 SelectedIndex="0"        
  12.  
  13.                 > 
  14.                     <ListBox.ItemTemplate> 
  15.                         <!--<DataTemplate> 
  16.                     <Image Source="{Binding Path=ProductImagePath}" /> 
  17.                 </DataTemplate>--> 
  18.  
  19.                         <DataTemplate > 
  20.                             <Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6"> 
  21.                                 <!-- Drop Shadow --> 
  22.                                 <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="4" Background="#44000000"> 
  23.                                     <Border.RenderTransform> 
  24.                                         <TranslateTransform X="5" Y="5" /> 
  25.                                     </Border.RenderTransform> 
  26.                                     <Border.BitmapEffect> 
  27.                                         <BlurBitmapEffect Radius="8" /> 
  28.                                     </Border.BitmapEffect> 
  29.                                 </Border> 
  30.                                 <!-- Image Template --> 
  31.                                 <Border Padding="4" Background="White" BorderBrush="#22000000" BorderThickness="1"> 
  32.                                     <StackPanel Orientation="Vertical"> 
  33.                                         <Image Height="150" Width="100" Source="{Binding Path=ProductImagePath}"/> 
  34.                                         <!--<Label Content="{Binding Metadata.DateImageTaken}"> 
  35.                                             <Label.ToolTip> 
  36.                                                 Only JPeg images with a stored thumbnail will display a thumbnail during preview. 
  37.                                             </Label.ToolTip> 
  38.                                         </Label>--> 
  39.                                     </StackPanel> 
  40.                                 </Border> 
  41.                             </Grid> 
  42.                         </DataTemplate> 
  43.  
  44.                     </ListBox.ItemTemplate> 
  45.  
  46.                     <ListBoxItem HorizontalContentAlignment="Stretch"  Background="Blue"></ListBoxItem> 
  47.                     <ListBoxItem HorizontalContentAlignment="Stretch" Background="Blue" Name="ListBoxItem1">Click Me</ListBoxItem> 
  48.                     <ListBoxItem HorizontalContentAlignment="Stretch" Background="Blue"></ListBoxItem> 
  49.                 </ListBox> 
  50.             </ScrollViewer> 
  51.         </GroupBox> 
  52.  
  53.  
  54.  <!-- Pop-Up Product Information Window --> 
  55.         <Popup Name="ProductInfo"  
  56.                    StaysOpen="False"    
  57.                    Placement="Center"   
  58.                    MaxWidth="200" 
  59.                    PopupAnimation="Slide"  
  60.                    AllowsTransparency = "False"> 
  61.  
  62.             <Border BorderBrush="Beige"  
  63.                                 BorderThickness="2"  
  64.                                 Background="White"> 
  65.  
  66.  
  67.                 <TextBlock Name="abc" Margin="10"   
  68.                                        TextWrapping="Wrap" >  
  69.                                 For more information, see 
  70.                             </TextBlock> 
  71.  
  72.             </Border> 
  73.         </Popup> 
  74.         <!-- Pop-Up Product Information Window --> 
  75.  
This is a code behind
Expand|Select|Wrap|Line Numbers
  1. Public Class PopupTest 
  2.  
  3.     Private Sub run_MouseEnter(ByVal sender As Object, ByVal e As MouseEventArgs) 
  4.         popLink.IsOpen = True 
  5.     End Sub 
  6.  
  7.     Private Sub lnk_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) 
  8.         Process.Start((CType(sender, Hyperlink)).NavigateUri.ToString()) 
  9.     End Sub 
  10.  
  11.     Private Sub ListBoxItem1_Selected(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles ListBoxItem1.Selected 
  12.         popLink.IsOpen = True 
  13.     End Sub 
  14. End Class 
  15.  
  16.  
case 1 : When I clicked on the term, it will popup and disapear when I clicked outside anywhere
Case 2 : I have listbox and have a list item named "click me" , when I clicked on this list item the popup will appear but when I click outside anywhere it is not going to be disapear.


Please help me to solve this problem


Thanking you in advanced
Reply


Similar XAML / WPF / Silverlight bytes