MVVM DataGridTextColumn BindingProxy

2019-08-14 04:36发布

问题:

I currently work on a project in WPF MVVM / Csharp. I would use a converter to determine the visibilitée column.

To do this, I try to go through a Proxy Binding but without results. Loading my DataGrid, its never passes the converter.

In my XAML:

<DataGridTextColumn Header="Ste. d'appartenance" Binding="{Binding Path=Prod_Cloture}" Visibility="{Binding Data.Prod_Cloture, Converter={StaticResource VisibilityColumn}, Source={StaticResource proxy}}"/>

My Binding Proxy in XAML:

 <DataGrid.Resources>
            <Helper:BindingProxy x:Key="proxy" Data="{Binding}"/>   
        </DataGrid.Resources>

And my file Binding Proxy :

public class BindingProxy : Freezable
{

    protected override Freezable CreateInstanceCore()
    {
        return new BindingProxy();
    }


    public object Data
    {
        get { return (object)GetValue(DataProperty); }
        set { SetValue(DataProperty, value); }
    }

    // Using a DependencyProperty as the backing store for Data.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty DataProperty =
        DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
}
标签: c# wpf xaml mvvm