请问ListView的列的坐标咋算
1、2、3、4、5、6、7、列的坐标,

解决方案 »

  1.   

    Columns[x] 的 Width 属性。但是因为渲染的不同,没办法得到精确的值。建议使用 Grid 一类的控件。
      

  2.   

    可以通过限定ListView的宽度来实现它
    //限定列宽度
    public class FixedWidthColumn : GridViewColumn {
        static FixedWidthColumn() {
            WidthProperty.OverrideMetadata(typeof(FixedWidthColumn),
                new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerceWidth)));
    }
     
    private static object OnCoerceWidth(DependencyObject o, object baseValue) {
            return baseValue;
        }
    }public double FixedWidth {
        get { return (double)GetValue(FixedWidthProperty); }
        set { SetValue(FixedWidthProperty, value); }
    }
     
    public static readonly DependencyProperty FixedWidthProperty =
        DependencyProperty.Register(
            "FixedWidth",
           typeof(double),           
            typeof(FixedWidthColumn),
            new FrameworkPropertyMetadata(double.NaN, new PropertyChangedCallback(OnFixedWidthChanged)));
     
    private static void OnFixedWidthChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) {
        FixedWidthColumn fwc = o as FixedWidthColumn;
        if (fwc != null)
            fwc.CoerceValue(WidthProperty);
    }
    private static object OnCoerceWidth(DependencyObject o, object baseValue) {
        FixedWidthColumn fwc = o as FixedWidthColumn;
        if (fwc != null)
            return fwc.FixedWidth;
        return baseValue;
    }然后在需要的地方调用这些方法就OK了!
      

  3.   

    Grid 一类的控件在工具箱的哪个地方,没找到呢,我是初学者,谢谢
      

  4.   

    看不懂诶!!是不是有些单词之间没空格...
    还有WidthProperty.OverrideMetadata在MSDN没找到这个属性呢?
      

  5.   

    DataGridView是怎么添加行的呢,ListView可以直接编辑行?