使用ItemsControl
缩放Slider
。问题是Thumb
和BorderThickness
的缩放方式是BorderThickness
变得太薄,几乎看不见或太厚。与Thumb
s相同。
如何阻止Thumb
和BorderThickness
扩展,同时仍允许Grid
扩展?
我想也许可以使用Converter
重新缩放Border
的厚度
BorderThickness="{Binding ElementName=MyItemsControl, Converter={StaticResource descaleConverter}}"
但Converter
仅应用一次,而在缩放ItemsControl
时则不会再调用。{/ p>
有什么想法吗?
<ItemsControl ItemsSource="{Binding Segments}" x:Name="MyItemsControl">
<ItemsControl.LayoutTransform>
<ScaleTransform
ScaleX="{Binding ElementName=scaleSlider,Path=Value}" />
</ItemsControl.LayoutTransform>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Width="{Binding Duration}" Height="100">
<Grid Opacity="0">
<local:ResizeThumb Height="6" Cursor="SizeNS" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<local:ResizeThumb Width="6" Cursor="SizeWE" VerticalAlignment="Stretch" HorizontalAlignment="Left" />
<local:ResizeThumb Width="6" Cursor="SizeWE" VerticalAlignment="Stretch" HorizontalAlignment="Right" />
</Grid>
<Grid IsHitTestVisible="False">
<Border BorderThickness="1,1,1,0" BorderBrush="Black" />
</Grid>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Slider
x:Name="scaleSlider"
Value="1" Minimum="0.01" Maximum="4"
/>
答案 0 :(得分:0)
我相信将逆变换应用于DataTemplate的子网格可以做你想要的,或者希望指向正确的方向。
<DataTemplate>
<Grid Width="{Binding Duration}" Height="100">
<Grid Opacity="0" LayoutTransform="{Binding ElementName=MyItemsControl, Path=LayoutTransform.Inverse}">
<local:ResizeThumb Height="6" Cursor="SizeNS" VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<local:ResizeThumb Width="6" Cursor="SizeWE" VerticalAlignment="Stretch" HorizontalAlignment="Left" />
<local:ResizeThumb Width="6" Cursor="SizeWE" VerticalAlignment="Stretch" HorizontalAlignment="Right" />
</Grid>
<Grid IsHitTestVisible="False"
LayoutTransform="{Binding ElementName=MyItemsControl, Path=LayoutTransform.Inverse}">
<Border BorderThickness="1,1,1,0" BorderBrush="Black" />
</Grid>
</Grid>
</DataTemplate>