zoukankan      html  css  js  c++  java
  • (WPF)GridView等比例显示

    1. 将ListView包裹在一个父Grid中
    2. 写一个与ListView平行的Grid,设置该Grid的列数与ListView中GridView的列数相同,将该Grid各列设置列宽按比例分配
    3. 将ListView中GridView的各列的Width绑定上述Grid的ActualWidth
    4. 这样,通过设置上述Grid各列的比例,就对应设置了ListView中GridView的各列的比例
    5. <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3">
          <Grid>
              <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="3*" />
                  <ColumnDefinition Width="2*" />
                  <ColumnDefinition Width="8*"/>
                  <ColumnDefinition Width="5*"/>
                  <ColumnDefinition Width="5*"/>
              </Grid.ColumnDefinitions>
              <Grid Grid.Column="0" x:Name="HumidifyEventLogCol0"/>
              <Grid Grid.Column="1" x:Name="HumidifyEventLogCol1"/>
              <Grid Grid.Column="2" x:Name="HumidifyEventLogCol2"/>
              <Grid Grid.Column="3" x:Name="HumidifyEventLogCol3"/>
              <Grid Grid.Column="3" x:Name="HumidifyEventLogCol4"/>
          </Grid>
      
          <ListView Name="HumidifyEventLog" Style="{StaticResource ListViewStyle}" ItemContainerStyle="{StaticResource ResourceKey=ListViewItemStyle}">
              <ListView.View>
                  <GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle}">
                      <GridViewColumn Header="设备" Width="{Binding ElementName=HumidifyEventLogCol0,Path=ActualWidth}" DisplayMemberBinding="{Binding Path=Source, Converter={StaticResource ChamberNameEnToCn}}"/>
                      <GridViewColumn Header="故障ID" Width="{Binding ElementName=HumidifyEventLogCol1,Path=ActualWidth}" DisplayMemberBinding="{Binding Path=Code}"/>
                      <GridViewColumn Header="故障描述" Width="{Binding ElementName=HumidifyEventLogCol2,Path=ActualWidth}" DisplayMemberBinding="{Binding Path=Remark}"/>
                      <GridViewColumn Header="故障开始时间" Width="{Binding ElementName=HumidifyEventLogCol3,Path=ActualWidth}" DisplayMemberBinding="{Binding Path=StartTime}"/>
                      <GridViewColumn Header="故障结束时间" Width="{Binding ElementName=HumidifyEventLogCol4,Path=ActualWidth}" DisplayMemberBinding="{Binding Path=EndTime}"/>
                  </GridView>
              </ListView.View>
          </ListView>
      </Grid>
  • 相关阅读:
    如何将Python项目发布到PyPI
    hashlib的md5计算
    使用hexo和coding建立静态博客站点
    mysql 使用记录
    linux QA
    linux 使用记录
    转载-linux内核长什么样
    mysql 更改默认字符集
    Say goodbye
    SSH proxycommand 不在同一局域网的机器ssh直连
  • 原文地址:https://www.cnblogs.com/xietianjiao/p/14923050.html
Copyright © 2011-2022 走看看