2
這個問題不僅僅是一個數據問題,而是一個整體。有一個簡單的辦法把的您可以使用擴展器來覆蓋WPF中的其他可視化樹元素嗎?
<Expander>(contents)</Expander>
元素在彈出窗口或別的東西,使其剛好覆蓋在上面的其他因素?
XAML:(我只是做了一個簡單的for循環來填充在構造函數中的「交通線」的一個視圖模型綁定,否則大多數虛擬機爲空)
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MVVM"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Expander ExpandDirection="Down" IsExpanded="True" HorizontalAlignment="Stretch">
<Expander.Header>
<TextBlock TextAlignment="Left" HorizontalAlignment="Center" VerticalAlignment="Center" Text="LOCATIONS" FontWeight="Bold"/>
</Expander.Header>
<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto" Height="300" HorizontalAlignment="Stretch">
<ItemsControl ItemsSource="{Binding Locs}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Margin="5" Content="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Expander>
</Grid>
<Label Grid.Row="1" Height="100" Content="Test Content" FontSize="32" />
</Grid>
</Window>
啓動應用程序和看起來不錯。
單擊擴展,現在它縮短了,但它跳躍的文字了。我在視覺樹中理解這是默認行爲,但是是否有一種簡單的方法可以將其包含在某個覆蓋圖中,如彈出窗口,在其摺疊時不會使其他文本跳轉?
沒錯我想要什麼,謝謝。 – djangojazz