Reputation: 21
In my WPF application I have image icon on MainWindow and I am showing/hiding popup window on click of image.
Placement property of popup is bottom and PlacementTarget is set to image.
Problem - All working fine but when I resize MainWindow, half of popup window is going outside of MainWindow. It has to be inside bounds of MainWindow. Popup window should display at bottom of image icon only.
My Code for Popup window...
<Popup Name="popup" AllowsTransparency="True"
Placement="Bottom" MouseDown="popup_MouseDown"
PlacementTarget="{Binding ElementName=TriangleIcon}">
<Border BorderThickness="3" BorderBrush="Gray"
Background="White" Height="150">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="3" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="3" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="10"/>
<RowDefinition/>
<RowDefinition Height="10"/>
<RowDefinition/>
<RowDefinition Height="10"/>
<RowDefinition/>
<RowDefinition Height="10"/>
<RowDefinition/>
<RowDefinition Height="10"/>
<RowDefinition/>
<RowDefinition Height="
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" Grid.Column="1"
Grid.ColumnSpan="5" FontSize="15"
Foreground="Gray" HorizontalAlignment="Center">
Dashboard Settings </TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1"
Grid.ColumnSpan="5" HorizontalAlignment="Left">
Local Rate : 12 $/kw. Click to change.</TextBlock>
<Button Width="50" Grid.Row="5" Grid.Column="1">Save</Button>
<Button Width="50" Grid.Row="7" Grid.Column="1">Print</Button>
<Button Width="50" Grid.Row="9"
Grid.Column="1">Log</Button>
</Grid>
</ScrollViewer>
</Border>
</Popup>
Upvotes: 2
Views: 1553
Reputation: 138
Set "Placement" property of popup window as "Custom" in Xaml and then in code behind set its height, weight and position on OptionsMenuPopup.CustomPopupPlacementCallback handler. Try it will work.
Upvotes: 4