私はちょっと奇妙な問題を抱えています。
これが状況です。私は を持っており、データをs に表示するようにListView
定義されたカスタムがあり、その中に含まれるもの (1 つのトグル ボタン + 1 つのカスタム コントロールを含む)があります。ただし、 をチェックすると、カスタム コントロールが表示され、同じ行にある他のすべてのコントロールが垂直方向の中央に移動します。理想的には、これらのメンバーがトップに留まることを望んでいます。可能な限りどこでも設定しようとしましたが、とにかく変わりません。GroupStyle
Expander
WrapPanel
StackPanels
StackPanel
ToggleButton
ToggleButton
VerticalAlignment="Top"
画像化された問題:
エキスパンダーの初期状態:
をクリックするToggleButton
と、次のようになります。
ご覧のとおり、[テスト分析] ボタンが中央に移動されています。元の場所と同じ場所にとどまりたいです。
さらに、これらのスタイルはすべて個別DataTemplate
の s オブジェクトで定義しました。ここにいくつかの軽いコードがあります (ここでは、問題に役に立たないものを削除しただけで、大量の XAML コードを読む必要はありません:)):
エキスパンダーのコンテンツ プロパティ:
<Expander.Content>
<WrapPanel Background="White" VerticalAlignment="Top">
<ItemsPresenter VerticalAlignment="Top"/>
</WrapPanel>
</Expander.Content>
リストのItemsPanel
:
<ItemsPanelTemplate >
<WrapPanel
Width="{Binding (FrameworkElement.ActualWidth),
RelativeSource={RelativeSource
AncestorType=Expander}}"
ItemWidth="{Binding (ListView.View).ItemWidth,
RelativeSource={RelativeSource AncestorType=ListView}}"
ItemHeight="{Binding (ListView.View).ItemHeight,
RelativeSource={RelativeSource AncestorType=ListView}}" />
</ItemsPanelTemplate>
リストのItemsTemplate
:
<StackPanel Orientation="Vertical" Height="Auto" Width="Auto" VerticalAlignment="Top" >
<ToggleButton BorderBrush="{x:Null}" Background="{x:Null}" IsChecked="{Binding Value.IsToLaunch, Mode=TwoWay}"
Command="{Binding DataContext.UpdateGroupCheckingsCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type UserControl}}}">
<Grid Background="Transparent">
<!-- Blah blah blah about the ToggleButton's content -->
</Grid>
</ToggleButton>
<my:UcReleaseChooser>
<!-- Blah blah blah about being visible if ToggleButton is Checked -->
</my:UcReleaseChooser>
</StackPanel>