1

I am facing one issue with the WPF popup control.
When we resize the window and move it, PopUp control remains at same position at which it was open previously and does not move with the window.
So what is the solution for this issue. please provide code snippet for the solution if any. Thanks :)

Xaml code for popup control is as follows:

<Popup x:Name="popNonTopMostPopup" Height="200" Width="220" AllowsTransparency="True" Placement="Right">
            <Grid Background="Transparent">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <fa:FontAwesome Grid.Column="0" Icon="Play" FontSize="30" HorizontalAlignment="Right" Rotation="180" VerticalAlignment="Top" Margin="0 7 -2 0" />
                <Border Grid.Column="1" BorderBrush="LightGray" Background="Black" CornerRadius="5" Height="200" Width="200">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Button x:Name="btnCustomPopup" Click="btnCustomPopup_Click" HorizontalAlignment="Right" Background="Transparent" Foreground="LightGray" BorderBrush="Transparent" Grid.Row="0">
                            <StackPanel Margin="0">
                                <fa:FontAwesome Icon="Close" VerticalAlignment="Center" />
                            </StackPanel>
                        </Button>
                        <Label x:Name="lblName" Grid.Row="1" Foreground="LightGray"/>
                        <Grid Grid.Row="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Label x:Name="lblDueDate" Foreground="LightGray" Content="Fristdatum: " Grid.Column="0" VerticalAlignment="Bottom" Visibility="Hidden"></Label>
                            <TextBlock x:Name="txtDueDate" Foreground="LightGray" HorizontalAlignment="Left" Grid.Column="1" VerticalAlignment="Center" Visibility="Hidden"></TextBlock>
                        </Grid>
                        <Separator Grid.Row="3"></Separator>
                        <TextBlock x:Name="txtComments" Foreground="LightGray" TextWrapping="WrapWithOverflow" Grid.Row="4" Margin="10 10 10 10"></TextBlock>
                    </Grid>
                </Border>
            </Grid>
        </Popup>

We have icons on map on click of which pop up control is displayed.Code for click event is as follows.

void pin_MouseLeftButtonDownForOrder(object sender, MouseButtonEventArgs e)
{
      // set the placement target of popup as pin mapicon
      popNonTopMostPopup.PlacementTarget = orderIcon;
      popNonTopMostPopup.IsOpen = true;
}
pankaj
  • 207
  • 6
  • 18
  • 2
    Provide Code pls – Peter Jun 23 '17 at 09:00
  • read this https://stackoverflow.com/help/mcve – MikeT Jun 23 '17 at 09:21
  • I updated the question with the code snippet @Peter – pankaj Jun 23 '17 at 12:24
  • I dont think that there is a super easy solution to this. But here is a Framework that is working pretty good - I am using it too in my current project. It provides features that u might wanna have :) ! https://github.com/punker76/MahApps.Metro.SimpleChildWindow . It is aviable in the nuget store - so pretty convenient. – Peter Jun 23 '17 at 12:38
  • Also it is open source - why not check out how they do it ? – Peter Jun 23 '17 at 13:02
  • Thanks :)..yes i will check this solution @Peter...but also is there any other solution you have then please suggest that...because changing the control could be the last thing i can do – pankaj Jun 23 '17 at 13:06

0 Answers0