我里面有一个Canvas和一个ToolBarPanel。
我想使用Thumb调整ToolBarPanel的大小,因此我将Thumb放在ToolBarPanel中。当我捕捉到Thumb的DragDelta时,宽度不会改变。以下是代码:
<Canvas x:Uid="userControlCanvas" Name="userControlCanvas" Width="300" Height="300">
<ToolBarPanel x:Uid="categoriesToolBar" Name="categoriesToolBar" Visibility="Visible"
Height="300" Width="10" Panel.ZIndex="100"
Background="#CCDCDCDC"
SizeChanged="toolbarSizeChanged">
<Thumb x:Name="splitPane" Cursor="SizeWE" Height="300" Canvas.Left="2" Width="8" DragStarted="splitPaneDragStarted" DragDelta="splitPaneDragging">
</Thumb>
</ToolBarPanel>
</Canvas>
和cs代码:
private void splitPaneDragging(object sender, DragDeltaEventArgs e) {
categoriesToolBar.Width = categoriesToolBar.ActualWidth + e.HorizontalChange;
//categoriesToolBar.InvalidateMeasure();
categoriesToolBar.UpdateLayout();
//categoriesToolBar.InvalidateArrange();
//categoriesToolBar.InvalidateVisual();
//categoriesToolBar.InvalidateMeasure();
//Width is always the initial width (150)
Console.WriteLine("ch=" + e.HorizontalChange + " tw=" + categoriesToolBar.Width + " aw=" + categoriesToolBar.ActualWidth);
}
private void toolbarSizeChanged(object sender, SizeChangedEventArgs e) {
// this is not fired when I try to change the width in splitPaneDragging method
}