1
在我的WPF應用程序中,我在MainWindow上有圖像圖標,並且在圖像單擊時顯示/隱藏彈出窗口。在wpf中調整父窗口大小時彈出窗口在父窗口外面
彈出窗口的Placement屬性是bottom,PlacementTarget設置爲image。
問題 - 所有工作正常,但當我調整MainWindow的大小時,彈出窗口的一半超出了MainWindow。它必須在MainWindow的範圍內。彈出式窗口只應顯示在圖像圖標的底部。
我的彈出窗口代碼...
<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>
您是否試過這種解決方案? –
是的..謝謝你abhishek它的工作.. –
哦,太棒了,歡迎。 –