我正在构建一个控件,允许管理一些项目并选择一个。它包括 aTextBox
和 aButton
允许打开Popup
所有发生的地方。
我想要一个包含System.Windows.Controls.Primitives.Popup
课程详细信息的项目列表。我正在使用Grid
2 列,第一个包含项目列表,第二个包含详细信息。
现在我想使用一个System.Windows.Controls.GridSplitter
控件来允许用户调整细节区域的大小。
问题是这在除Popup
控件内部之外的任何地方都有效。我的问题是,我应该使用其他一些模拟..Popup
行为的控件Window
还是有任何其他方法可以实现这一点。
已编辑:如果我设置 Popup 的 Width 属性,它会起作用,因为 Popup 不会尝试适应其内容。但我想保留这种行为..
我的计划是在控件中添加复杂的动画Popup
。
代码:
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox Grid.Column="0" Grid.Row="0" Text="Selected Item" />
<ToggleButton Grid.Row="0" Grid.Column="1" Focusable="False">
<Grid>
<TextBlock Text="Select" />
<Popup StaysOpen="False" Width="700" VerticalAlignment="Bottom" IsOpen="{Binding Path=IsChecked,
RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton, AncestorLevel=1},
Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" PlacementTarget="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ToggleButton, AncestorLevel=1}}">
<local:MyManagementControl />
</Popup>
</Grid>
</ToggleButton>
</Grid>
...
MyManagementControl 包含:
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ListView Grid.Row="0" Grid.Column="0">
...
</ListView>
<GridSplitter Grid.Column="0" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch" />
<Grid Grid.Row="0" Grid.Column="1">
...Details...
</Grid>
</Grid>
...