2017-01-23 50 views
0

我使用自定义的popupwindow向用户显示一些内容。为什么棱镜的弹出窗口动作窗口内容没有拉伸到它的父窗口?

<i:Interaction.Triggers> 
    <mvvm:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}"> 
     <mvvm:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"> 
      <mvvm:PopupWindowAction.WindowContent> 
       <views:DataFeedManagerView/> 
      </mvvm:PopupWindowAction.WindowContent> 
     </mvvm:PopupWindowAction> 
    </mvvm:InteractionRequestTrigger> 
</i:Interaction.Triggers> 

一切都很好,直到用户尝试调整弹出窗口的大小。内容将被集中到它的父窗口。

Popup Window Screenshot

对于了解什么是我的错,我尝试探索棱镜的互动样本,我看到有同样的问题了。我怎么解决这个问题?

回答

2

我想向你道歉(MM8),因为我的问题是不完整,所以你的回答也不完整。我明白,看到你的答案后。

为什么你的回答不能解决我的问题? 因为我的DataFeedManagerView必须是Width =“960”和Height =“540”的固定长度。当选择改变时,左侧有一个项目控件,中间有内容控件,其内容动态变化(当然内容大小也在变化)与选择。

延迟细节&解决方案。 从我的ShellView的第一个xaml在我的问题中,我的弹出窗口是DataFeedManagerView,它具有Width =“960”和Height =“540”的固定长度。所以当我调整弹出窗口时,它将集中到我的用户控件。所以很快只能从DataFeedManagerView中删除宽度为&的xaml部件,它会延伸到像我想要的那样弹出窗口内容。但删除后,当弹出窗口显示在屏幕上,它的大小将会太大,我想再次将它的大小设置为固定值。为了解决这个问题,我还会给弹出窗口一个样式。所以我的问题的解决方案是从DataFeedManagerView删除固定宽度&高度属性并更改像下面的ShellView xaml;

<i:Interaction.Triggers> 
    <mvvm:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}"> 
     <mvvm:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"> 
      <mvvm:PopupWindowAction.WindowStyle> 
       <Style TargetType="Window"> 
        <Setter Property="Width" Value="960"/> 
        <Setter Property="Height" Value="540"/> 
       </Style> 
      </mvvm:PopupWindowAction.WindowStyle> 
      <mvvm:PopupWindowAction.WindowContent> 
       <views:DataFeedManagerView/> 
      </mvvm:PopupWindowAction.WindowContent> 
     </mvvm:PopupWindowAction> 
    </mvvm:InteractionRequestTrigger> 
</i:Interaction.Triggers> 

我希望我的问题&答案将帮助别人。谢谢。

1

我该如何解决这个问题?

在官方Prism示例中,它只是删除CustomPopupView UserControl的显式宽度的问题。您可以通过设置宽度这样做是为了double.NaN

<prism:PopupWindowAction> 
    <prism:PopupWindowAction.WindowContent> 
     <views:CustomPopupView Width="NaN" /> 
    </prism:PopupWindowAction.WindowContent> 
</prism:PopupWindowAction> 

你应该能够同你DataFeedManagerView:

<mvvm:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True"> 
    <mvvm:PopupWindowAction.WindowContent> 
     <views:DataFeedManagerView Height="NaN" Width="NaN" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> 
    </mvvm:PopupWindowAction.WindowContent> 
</mvvm:PopupWindowAction>