現在のところ、WPFでボックスの形でコントロールを表示してコード化する必要はありません。ここに私がそれを見せたいものの実例があります:完全な長方形(バインディングの幅と高さ)のコントロールを保持するWPF
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="120"/>
<RowDefinition Height="3" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<Button Margin="6" VerticalAlignment="Stretch" Width="{Binding Path=ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="http://blog.joeclarmusic.com/images/rss-icon.jpg" />
<TextBlock Foreground="Black" TextAlignment="Center" Grid.Row="1" FontSize="11" Text="{Binding Path=Name}" Margin="0, 5, 0, 0" HorizontalAlignment="Center" TextWrapping="Wrap" />
</Grid>
</Button>
</StackPanel>
<GridSplitter Grid.Row="1" Background="#DDDDDD" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>
[OK]これはすべてクールでよくあります。私の現在のデザインでは、ItemsControlを使用して画像のリストを表示しています。このようなリストはウィンドウの幅を超えることができるので、VerticalScrollBarが無効になっているStackPanelの周りにScrollViewerを追加したいと思っていました(私は左から右にしか流れないので、HorizontalScrollBarが必要です)。私のコンピュータでkaxaml 1.7.1で動作している上記の
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="120"/>
<RowDefinition Height="3" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ScrollViewer>
<StackPanel Orientation="Horizontal">
<Button Margin="6" VerticalAlignment="Stretch" Width="{Binding Path=ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image Source="http://blog.joeclarmusic.com/images/rss-icon.jpg" />
<TextBlock Foreground="Black" TextAlignment="Center" Grid.Row="1" FontSize="11" Text="{Binding Path=Name}" Margin="0, 5, 0, 0" HorizontalAlignment="Center" TextWrapping="Wrap" />
</Grid>
</Button>
</StackPanel>
</ScrollViewer>
<GridSplitter Grid.Row="1" Background="#DDDDDD" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</Grid>
イメージ:ScrollViewerのを追加した後
jonatan.nilsson.is/wpf_with_scrollviewer.jpg
をあなたはKaxamlでそれを実行した場合(またはWPFウィンドウ/ページで)button will now keep on getting bigger and bigger (both width and height)。私が行った唯一の変更は、StackPanelの周りにScrollViewerを追加することです。それ以外のものはすべて同じですが、なぜスクロールビューワ内で大きくなっていくのですか?
私はここで間違っていますか?
編集: 2番目の例の結果のイメージが追加されました。
それからあなたはもっと見るべきです。 2番目の例はScrollViewerを含み、前の例はScrollViewerを含みません。これはあなたにとって大きな変化には見えませんが、私を信頼すれば、最終結果は全く異なるレベルにあります。 2番目の例では、ボタンは自動的に無限に高速に無限に拡大します。 Kaxamlで試してみてください。 –