Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
XamDataGrid column is not visible/hide basis on property value.
posted

Hi,

I have bool property ShowDateOfService. Setting true or false value to ShowDateOfService property based on some condition but XamDataGrid column is not visible/hide.

My Code is here:

public class LinkToDocumentViewModel : ViewModelBase

{

 public ObservableCollection<DocumentRow> DocumentsToLink { get; set; }

 public bool ShowDateOfService { get; private set; }

#region Constructor
public LinkToDocumentViewModel(ReferralDocumentLinks referral)
{
ReferralDocumentInformation = referral;
Initialize();
}

public void Initialize()
{

ShowDateOfService =false;

GetSearchedDocuments();

}

private void GetSearchedDocuments()

{

if(basedonDate = 1)

ShowDateOfService =true;

else

ShowDateOfService =false;

}

}

LinkUnlinkToDocument.xmal as below

<igDP:XamDataGrid x:Name="DocumentToLinkGrid" DataSource="{Binding DocumentsToLink}" BorderBrush="Gray" BorderThickness="1" Width="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" GroupByAreaLocation="None" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0,5,0,0" ScrollingMode="Immediate">

<igDP:Field AllowEdit="False" Name="DateOfService" Label="Date of Service" Width="*" Visibility="{Binding DataContext.ShowDateOfService,Converter={StaticResource             BooleanToVisibilityConverter},RelativeSource={RelativeSource FindAncestor}}">

<igDP:Field.Settings>
<igDP:FieldSettings EditorStyle="{StaticResource DateEntryFormatStyle}"/>
</igDP:Field.Settings>
</igDP:Field>

 </igDP:XamDataGrid>

-------------------------------------------------

I used BooleanToVisibilityConverter for Data grid column and Bind ShowDateOfService value.

But DataGrid column is not hide when i set ShowDateOfService =false.

Please suggest how to hide XamDataGrid column.

Parents
No Data
Reply
  • 34510
    Offline posted

    Hi P R,

    If you are using 14.2 or 15.1, please see the following documentation: http://help.infragistics.com/doc/WPF/2015.1/CLR4.0/?page=xamDataGrid_Binding_Field_FieldLayout_to_MVVM.html

    The other thing you need to consider is that ShowDateOfService does not implement INotifyPropertyChanged, so when you change it's value it will not update the UI.  You need to implement INotifyPropertyChanged on that property if you want the UI to react to it.

Children