1

我有一个 ToggleButton,当单击它时,将其设置IsActionMenuOpen为 true,以便可以显示弹出窗口。我想要的结果是弹出窗口的位置会像这里一样在右下角。关于如何做到这一点的任何想法?此外,如果正在调整窗口大小,是否可以找到解决方案以使弹出窗口也移动?

<ToggleButton x:Name="PART_TGAction">
                        <ToggleButton.Template>
                            <ControlTemplate>
                                <TextBlock x:Name="PART_SubjectActions"  
                                        Text="Actions" 
                                        Margin="4,0,0,0" 
                                              PreviewMouseLeftButtonDown="PART_SubjectActions_PreviewMouseLeftButtonDown"
                                        />
                            </ControlTemplate>
                        </ToggleButton.Template>
                    </ToggleButton>
                    <Popup IsOpen="{Binding IsActionMenuOpen, Mode=OneWay}" 
                             x:Name="PART_Popup">
                        <Border Background="White">
                            ......
                        </Border>
                    </Popup>
4

1 回答 1

1

通过将它放在 UserControl 的 Loaded 事件中,我能够让它工作:

PART_Popup.CustomPopupPlacementCallback += (Size popupSize, Size targetSize, Point offset) => new[] { new CustomPopupPlacement() { Point = new Point(targetSize.Width - popupSize.Width, targetSize.Height) } };
于 2012-09-17T19:23:54.110 回答