forum

Home / DeveloperSection / Forums / Popup appearing on mouse over

Popup appearing on mouse over

Anonymous User605309-Aug-2013
Hi Mindstick!
I want a popup to appear every time I hover a togglebutton. It then needs to stay open until I click somewhere else in the application. The code below works fine on start up but as soon as I check or uncheck the togglebutton the popup refuses to appear. Any ideas on what I'm doing wrong?

The WPF code

        <ToggleButton Name="btnLogFile" Style="{StaticResource StandardToggle}"
                      Grid.Row="1" Grid.Column="3" Margin="0,3,3,0" 
                      MouseEnter="btnLogFile_MouseEnter">
            <Path Margin="7" SnapsToDevicePixels="True" Stretch="Uniform"
                Stroke="{StaticResource TextLight}" StrokeThickness="2">
                <Path.Data>
                    <GeometryGroup FillRule="Nonzero">
                        <PathGeometry Figures="M 0 0 L 20 0 L 20 10 L 30 10 L 30 40 L 0 40 Z" />
                        <PathGeometry Figures="M 20 0 L 22 0 L 30 8 L 30 10" />
                    </GeometryGroup>
                </Path.Data>
            </Path>
        </ToggleButton>
        <Popup Name="popLogFile"
               PlacementTarget="{Binding ElementName=btnLogFile}" Placement="Custom"
               HorizontalOffset="0" VerticalOffset="0"
               MouseLeftButtonDown="popLogFile_MouseLeftButtonDown">
            <Border Background="{StaticResource BackgroundDark}" BorderBrush="{StaticResource TextBoxBorder}" BorderThickness="1"
                    Width="300" Height="Auto">
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="3" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="3" />
                        <ColumnDefinition Width="22" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="22" />
                    </Grid.RowDefinitions>

                    <TextBlock Margin="0,1" Grid.Row="0" Grid.Column="0" Foreground="{StaticResource TextLight}" HorizontalAlignment="Right">Directory</TextBlock>
                    <TextBox Name="logfilePath" Grid.Row="0" Grid.Column="2" Grid.ColumnSpan="3"
                             Style="{StaticResource StandardTextBox}"
                             Foreground="{StaticResource TextLight}">
                        C:\logfile.txt
                    </TextBox><!-- Button made invisible for the time being -->
                    <Button Name="btnBrowseLogfile" Style="{StaticResource StandardButton}" Grid.Row="0" Grid.Column="4" Visibility="Collapsed">...</Button>

                </Grid>
            </Border>
        </Popup>
And the togglebutton's mouse event:

    private void btnLogFile_MouseEnter(object sender, MouseEventArgs e)
    {
        this.popLogFile.IsOpen = true;
        this.popLogFile.StaysOpen = false;
    }
tanks in advance


Updated on 10-Aug-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By