Datagridcolumn: Binding Visibility and Width via BindingProxy show different behavior

后端 未结 1 593
悲&欢浪女
悲&欢浪女 2021-01-28 18:35

As the columns of a data grid aren\'t in the visual tree of datagrid I\'m m using this approach of Binding Proxy to bind Visibility of a DataGridTextColumn.

<
相关标签:
1条回答
  • 2021-01-28 19:09

    The type of the Width property of a DataGridColumn is DataGridLength and not double.

    Change type of your source property:

    public DataGridLength Width
    {
        get { return m_width; }
        set { m_width = value; OnPropertyChanged("Width"); }
    }
    
    DataGridLength m_width;
    

    And the Mode of the Binding:

    <DataGridTextColumn Header="ProductId1" Binding="{Binding Path=Result[1]}"
                        Visibility="{Binding Data.Columns[0].Visible, Source={StaticResource proxy}}" 
                        Width="{Binding Data.Columns[0].Width, Source={StaticResource proxy}, Mode=TwoWay}" />
    
    0 讨论(0)
提交回复
热议问题