Hi,
I'm trying to set the Visibility of a TextColumn using binding (MVVM style, INotifyPropertyChanged...):
Visibility="{Binding ElementName=LayoutRoot, Path=DataContext.MyVisibilityProperty}"
Somehow this doesn't work. The MyVisibilityProperty raises the PropertyChanged event, but nothing happens. How can I get this to work?
Thanks,
Arjen
Hi, When I followed that approach, the visibility works fine but I think the ItemsSource of my XamGrid is not binding properly because the data is not displayed
<ig:XamGrid x:Name="dataGrid" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="6" AutoGenerateColumns="False" KeyboardNavigation="AllLayouts" ItemsSource="{Binding Employees,Source={StaticResource ViewModel}}" ColumnWidth="120">
<ig:TextColumn Key="FirstName" Tag="{StaticResource ViewModel}" IsHideable="False" IsFixed="Left" >
<ig:TextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="First Name"/>
</DataTemplate>
</ig:TextColumn.HeaderTemplate>
</ig:TextColumn>
</XamGrid>
The visibility works but the data binding does not work
Hi Petar,
This was indeed the solution. Thanks.
Hi Arjen,
I looked more thourougly into this and found a solution that should work better in your situation: Visibility={Binidng isVisible, Source={StaticResource myViewModel}
Hope this suits you better. Please let me know if you got everything working.
Regards Petar.
Hello Arjen,
I have been looking into this and do see what you mean. This is expected since the TextColumn does not derive from the FrameWorkElement class, but rather inherits DependencyObject, meaning it does not have a DataContext property itself which can be automatically populated from the parent. This is why the binding doesn’t work.
What you can do is use the Tag property to hold your DataContext objects and bind the visibility to it using a Self RelativeSource like so:
<igDataGrid:TextColumn Key="Age" Tag="{StaticResource myViewModel}" Visibility="{Binding RelativeSource={RelativeSource Self}, Path=Tag.isVisible}" />
Hope this helps.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support