ウィンドウの左隅を占有し、ウィンドウの高さに合わせて調整するウィンドウにスクロール可能な wpf ツリービュー コントロールをレンダリングする方法。グリッドとドックパネルを試してみましたが、高さを指定しないとスクロールバーが表示されません。XAML マークアップで回答してください。
1409 次
1 に答える
2
これが必要かどうか教えてください:
<Window x:Class="WpfApplication6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Name="window" Height="350" Width="525">
<Grid>
<TreeView
ItemsSource="{Binding ElementName=window, Path=TreeviewDummySource}"
Background="Gray"
Width="150"
HorizontalAlignment="Left"
ScrollViewer.VerticalScrollBarVisibility="Visible"/>
</Grid>
</Window>
ダミーアイテムソース:
public int[] TreeviewDummySource
{
get { return treeviewDummySource; }
}
private int[] treeviewDummySource = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
したがって、ScrollViewer のコンテンツが使用可能なサイズよりも大きい場合にのみ、ScrollBar が表示されるというトリックがあります。ScrollViewer.VerticalScrollBarVisibility="Visible"
TreeView プロパティで指定することにより、スクロールビューアは常に存在します (有効または無効)。ウィンドウの高さを変更して、ScrollBar がどのように有効になるかを確認してください。
于 2012-11-09T08:28:38.530 に答える