DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006
    Posts
    1

    WPF Popup Problem

    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.
    Code:
     <!-- Middle Product List --> 
            <GroupBox Grid.Column="1" Grid.Row="2"> 
                <ScrollViewer VerticalScrollBarVisibility="Disabled"  HorizontalScrollBarVisibility="Disabled"> 
                    <ListBox Style="{DynamicResource PhotoListBoxStyle}"  
                    Name ="PhotoListBox"  
                    Margin="5"  
                    SelectionMode="Single"  
                    ItemsSource="{Binding}"  
                    HorizontalAlignment="Center"  
                    VerticalAlignment="Center"  
                    SelectedIndex="0"        
                     
                    > 
                        <ListBox.ItemTemplate> 
                            <!--<DataTemplate> 
                        <Image Source="{Binding Path=ProductImagePath}" /> 
                    </DataTemplate>--> 
     
                            <DataTemplate > 
                                <Grid VerticalAlignment="Center" HorizontalAlignment="Center" Margin="6"> 
                                    <!-- Drop Shadow --> 
                                    <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="4" Background="#44000000"> 
                                        <Border.RenderTransform> 
                                            <TranslateTransform X="5" Y="5" /> 
                                        </Border.RenderTransform> 
                                        <Border.BitmapEffect> 
                                            <BlurBitmapEffect Radius="8" /> 
                                        </Border.BitmapEffect> 
                                    </Border> 
                                    <!-- Image Template --> 
                                    <Border Padding="4" Background="White" BorderBrush="#22000000" BorderThickness="1"> 
                                        <StackPanel Orientation="Vertical"> 
                                            <Image Height="150" Width="100" Source="{Binding Path=ProductImagePath}"/> 
                                            <!--<Label Content="{Binding Metadata.DateImageTaken}"> 
                                                <Label.ToolTip> 
                                                    Only JPeg images with a stored thumbnail will display a thumbnail during preview. 
                                                </Label.ToolTip> 
                                            </Label>--> 
                                        </StackPanel> 
                                    </Border> 
                                </Grid> 
                            </DataTemplate> 
     
                        </ListBox.ItemTemplate> 
                         
                        <ListBoxItem HorizontalContentAlignment="Stretch"  Background="Blue"></ListBoxItem> 
                        <ListBoxItem HorizontalContentAlignment="Stretch" Background="Blue" Name="ListBoxItem1">Click Me</ListBoxItem> 
                        <ListBoxItem HorizontalContentAlignment="Stretch" Background="Blue"></ListBoxItem> 
                    </ListBox> 
                </ScrollViewer> 
            </GroupBox>  
     
     <!-- Pop-Up Product Information Window --> 
            <Popup Name="ProductInfo"  
                       StaysOpen="False"    
                       Placement="Center"   
                       MaxWidth="200" 
                       PopupAnimation="Slide"  
                       AllowsTransparency = "False"> 
     
                <Border BorderBrush="Beige"  
                                    BorderThickness="2"  
                                    Background="White">  
     
                    <TextBlock Name="abc" Margin="10"   
                                           TextWrapping="Wrap" >  
                                    For more information, see 
                                </TextBlock> 
     
                </Border> 
            </Popup> 
            <!-- Pop-Up Product Information Window -->
    This is a code behind
    Code:
    Public Class PopupTest 
     
        Private Sub run_MouseEnter(ByVal sender As Object, ByVal e As MouseEventArgs) 
            popLink.IsOpen = True 
        End Sub 
     
        Private Sub lnk_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) 
            Process.Start((CType(sender, Hyperlink)).NavigateUri.ToString()) 
        End Sub 
     
        Private Sub ListBoxItem1_Selected(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles ListBoxItem1.Selected 
            popLink.IsOpen = True 
        End Sub 
    End Class
    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
    Last edited by Hack; 12-02-2008 at 07:21 AM. Reason: Added Code Tags

  2. #2
    Join Date
    Jan 2009
    Posts
    3
    I have run into the same issue where the Popup will not disappear when the IsOpen property is set to True in the LisBoxItem's Selected event handler. I do not understand why this is the case, although I have not looked deeply into it.

    Regardless, it looks like you found a workaround here:
    http://social.msdn.microsoft.com/For...-827483d78df7/

    There may also be a solution to the problem that does not need to make use of Popups, but that's for you to decide given your particular scenario.
    Last edited by gurge60; 03-25-2009 at 06:14 PM.

Similar Threads

  1. a very weird problem (AGAIN!!!)
    By Michael in forum ASP.NET
    Replies: 14
    Last Post: 02-24-2006, 08:54 AM
  2. Close popup window and reload parent form
    By ankushbindra in forum ASP.NET
    Replies: 1
    Last Post: 11-28-2005, 03:50 PM
  3. Replies: 3
    Last Post: 11-16-2005, 06:15 PM
  4. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 04:40 AM
  5. Replies: 0
    Last Post: 06-23-2000, 02:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links