This is a migrated thread and some comments may be shown as answers.

Collection elements bound to GridViewColumns

4 Answers 75 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 28 Mar 2012, 02:10 PM

Hello Telerik,
    first; my apologises. I have searched the GridView forum for answers to the following question and came up with nothing useful.
    The same goes for Google.

Problem:
    I have a ObservableCollection containing a 'ColumnVisibility' class - which is bound to a ComboBox control.
    But I am unable to specify a particular indexed element to the RadGridView's columns (bound to IsVisible property, see below).

<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=DetailsBAMCollection.VendorName}"
                    Header="Vendor"
                    Width="*"
                    IsVisible="{Binding Path=ColumnData[0].ColumnVisible, NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"/>
    
As you can see, the DataMemberBinding references a different collection and I have previously used the RadGridView's itemsource property to attach this collection to the Grid - neither gave me the desired effect (which is to hide certain columns based upon the user's ComboBox selections).

Can you give me any pointers?

4 Answers, 1 is accepted

Sort by
0
Adam
Top achievements
Rank 1
answered on 28 Mar 2012, 02:41 PM
 .
0
Pavel Pavlov
Telerik team
answered on 29 Mar 2012, 01:19 PM
Hi,

Does your ColumnVisible property implement the INotifyPropertyChanged interface correctly ?  Do you get binding expression errors in the output window of Visual studio ?


All the best,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Adam
Top achievements
Rank 1
answered on 29 Mar 2012, 02:00 PM

Hi Pavel,

Yes. ColumnVisible's property implements INotify correctly and I have configuered my Options --> Debugging --> WPF Trace Settings --> Data Binding field to "Information", which should provide me with the relevant info in output window... but I get nothing connected to the column's IsVisibility binding.

I have gotten around this problem by defining comboboxitems (containers for each set of Column-Visibility bound controls) individually in xaml (instead of using a collection of data to both create the Column-Visibility control content and GridViewdataColumn's IsVisible binding values). I then used the x:Name property to bind each checkbox's IsChecked property (the checkbox is a part of each ComboBoxItem) to its associated GridViewDataColumn. This approach has worked and I do not think that it breaks any MVVM rules... its just not very dynamic.
0
Adam
Top achievements
Rank 1
answered on 17 Apr 2012, 04:42 PM

** Further Update **

After modifying a theme and applying it to my project I am now able to bind correctly to all my controls...I think the problems I had stemed from missing or modified xaml datatemplates!!
Tags
GridView
Asked by
Adam
Top achievements
Rank 1
Answers by
Adam
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or