C# 如何在应用程序窗口wpf中保持弹出窗口

C# 如何在应用程序窗口wpf中保持弹出窗口,c#,.net,wpf,user-interface,caliburn,C#,.net,Wpf,User Interface,Caliburn,我一直试图在按下按钮时弹出一个窗口。 然而。假设我在弹出窗口上有很多文本,然后它可以越过应用程序窗口的边界 我如何告诉弹出窗口在xaml代码中保持在应用程序窗口范围内 在xaml代码中提供一些示例,说明如何让弹出元素保留在应用程序中,这将是非常好的 谢谢 Xaml代码: ... <ToggleButton Grid.Row="1" Grid.Column="1" Margin="0,4" x:Name="Somethingname" Height="

我一直试图在按下按钮时弹出一个窗口。 然而。假设我在弹出窗口上有很多文本,然后它可以越过应用程序窗口的边界

我如何告诉弹出窗口在xaml代码中保持在应用程序窗口范围内

在xaml代码中提供一些示例,说明如何让弹出元素保留在应用程序中,这将是非常好的

谢谢

Xaml代码:

...
    <ToggleButton Grid.Row="1" Grid.Column="1" Margin="0,4"
        x:Name="Somethingname"
        Height="30"
        Template="{StaticResource ComboBoxToggleButton}"
        Content="Hello man"/>
    <Popup Grid.Row="1" Grid.Column="1" x:Name="PopupMe"
            Style="{StaticResource PopupStyle}"
            ClipToBounds="True">

            <TreeView ItemsSource="{Binding SomeObservableCollection}"
                      Width="{Binding ElementName=DetaljerHjemmmelToggler, Path=ActualWidth}"
                      ItemTemplate="{StaticResource SomeTemplate}"
                      cal:Message.Attach="[Event SelectedItemChanged] = [Action TreeView_SelectedItem($this, $source)]">

             </TreeView>
    </Popup>
    ...     
。。。
...     
在ResourceDictionary XAML文件中:

<HierarchicalDataTemplate x:Key="SomeTemplate" ItemsSource="{Binding ChildrenCollection}">
    <TextBlock Text="{Binding Path=TekstBlaaah}" Style="{StaticResource Label}"/>
</HierarchicalDataTemplate>

    <Style TargetType="{x:Type Popup}" x:Key="PopupStyle">
    <Setter Property="IsOpen" Value="{Binding ElementName=Somethingname, Path=IsChecked}"/>
    <Setter Property="AllowsTransparency" Value="True"/>
    <Setter Property="PlacementTarget" Value="{Binding ElementName=Somethingname}"/>
    <Setter Property="PopupAnimation" Value="Slide"/>
    <Setter Property="StaysOpen" Value="False" />
    <Setter Property="Placement" Value="Bottom"/>
</Style>

查看:


示例也可用

好的,很好。请在问题中加入弹出窗口的xaml代码。这可能会有所帮助,谢谢。似乎使用ModalDialog的一部分是有效的。只是不是所有的,因为我以前用过它,而且它很笨重:((谢谢兄弟!:D)