我有一个用 WPF 制作的自定义控件,其中ControlTemplate
包含一个Popup
控件:
<Popup x:Name="PART_Popup"
PopupAnimation="Fade"
Width="{TemplateBinding Width}"
AllowsTransparency="True"
IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsPopupOpen, Mode=OneWay}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_Border}">
自定义控件由以下代码托管在 WinForms 应用程序中:
var wpfHost = new ElementHost();
wpfHost.Dock = DockStyle.Fill;
wpfHost.Child = new TitleBar();
Controls.Add(wpfHost);
当窗口位置发生变化时,我想使弹出窗口重新定位。我在这里看到了几个答案,建议获取窗口参考并注册他的LocationChanged
活动,但它对我不起作用,因为它托管在 winForms 窗口中。
任何的意见都将会有帮助 :)