XamDataGrid visibilty column not working using MVVM

I am trying to implement a XamDataGrid visibilty column in MVVM architecture and it does not seem to work.

I do the following:

Adding the Visiblility property for an unrelated field -

<igDP:UnboundField Name="gridCustomerId" 
                   Label="ID" 
                   Binding="{Binding customerid, 
                                     Mode=TwoWay, 
                                     UpdateSourceTrigger=PropertyChanged}" 
                   Visibility="{Binding ShowCustomerIDColumn, 
                                        Mode=TwoWay, 
                                        UpdateSourceTrigger=PropertyChanged}">

In my view model, adding a proprietary visibility type:

//ToShow CustomerID Column
private Visibility showCustomerIDColumn; 
public Visibility ShowCustomerIDColumn 
{
    get
    {
        return showCustomerIDColumn; 
    }

    set
    {
        showCustomerIDColumn=value; 
        InvokePropertyChanged("ShowCustomerIDColumn"); 
    }    
}

Then in the command handler using the following code:

if(ShowCustomerIDColumn == Visibility.Hidden) 
    ShowCustomerIDColumn = Visibility.Visible; 
else
    ShowCustomerIDColumn = Visibility.Hidden; 

InvokePropertyChanged("ShowCustomerIDColumn");

Anyone with a solution?

Cheers, Anshuman

+5
source share
2 answers

I do not think that UnboundField is part of the tree of elements, so you cannot bind its property as usual. Josh Smith wrote a blog post about binding it to the fields http://blogs.infragistics.com/blogs/josh_smith/archive/2008/06/06/binding-a-xamdatagrid-field-property.aspx .

+3

, , Fields Class ( UnboundField Field), .

.

View Visibility Property

. Label/RowSpan,

See Label Property That Supports Binding

# ( , ):

fieldlayout.Fields[node.Name].Visibility = node.Visibility ? Visibility.Visible : Visibility.Collapsed;
+1

All Articles