这是我的代码:
<Border BorderBrush="BlueViolet" BorderThickness="9">
<ListView x:Name="lbEOParam" ItemsSource="{Binding}"
Margin="0,0,0,0"
HorizontalContentAlignment="Stretch">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Aqua" BorderThickness="7" >
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Slider Grid.Row="0" Grid.Column="0"
Minimum="{Binding MinValueDevice}"
Maximum="{Binding MaxValueDevice}"
Value="{Binding Value, Mode=TwoWay}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="0 0 0 0"></Slider>
</Grid>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Border>
</Grid>
结果如下:
为什么我的滑块没有全宽?
答案 0 :(得分:3)
您需要将ListViewItem
的{{1}}属性设置为HorizontalContentAlignment
,以使其延伸到Stretch
的宽度。例如,您可以像ListView
这样设置属性:
Style