我是WPF的新手。在WPF应用程序中,我使用了Listview
显示下面列表视图的快照: -
问题是列表视图(gridview)中网格列标题和垂直滚动条之间的空白空间
我认为它是因为网格的最后一个空白列是否有任何方法可以删除空白列或任何对齐属性,以扩展我的列“设备名称”的宽度
下面是我的Listview-Gridview的XAML
<ListView x:Name="lstviewDevices" Height="263" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Left" Margin="37,89,0,0" VerticalAlignment="Top" Width="128" SelectionChanged="lstviewDevices_SelectionChanged">
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="#adb8ca" />
<Setter Property="Foreground" Value="#fff" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontFamily" Value="sans-serif" />
<Setter Property="FontWeight" Value="SemiBold" />
<!--<Setter Property="Margin" Value="3,0,-7,1" />-->
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="#337ab7" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontFamily" Value="Roboto" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Device Name" Width="Auto" DisplayMemberBinding="{Binding DeviceName}"/>
</GridView>
</ListView.View>
</ListView>
是否有相同的输入?
提前致谢
我稍微修改了你的代码..尝试在listview中设置填充并根据你的要求进行修改
<ListView x:Name="lstviewDevices" Padding="0,0,-3,0" Height="263" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Left" Margin="37,89,0,0" VerticalAlignment="Top" Width="228" >
<ListView.Resources>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="#adb8ca" />
<Setter Property="Foreground" Value="#fff" />
<Setter Property="FontSize" Value="15" />
<Setter Property="FontFamily" Value="sans-serif" />
<Setter Property="FontWeight" Value="SemiBold" />
<!--<Setter Property="Margin" Value="3,0,-7,1" />-->
</Style>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="White" />
<Setter Property="Foreground" Value="#337ab7" />
<Setter Property="FontSize" Value="13" />
<Setter Property="FontFamily" Value="Roboto" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Device Name" Width="Auto" DisplayMemberBinding="{Binding DeviceName}"/>
</GridView>
</ListView.View>
</ListView>