-1
<DataGridTextColumn Header="Amount($)" Width="*" Binding="{Binding Path = Amount}">
                <DataGridTextColumn.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Path=Tran_Code}" Value=**"DEP"**>
                                <Setter Property="IsEnabled" Value="False"/>                                 
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>

Instead of just one values (as of now its DEP),the cell should be enabled for certain set of values

Arjun
  • 15
  • 4
  • – Arjun Nov 13 '15 at 05:43
  • 1
    What's the expected result? What doesn't work? Please use the "edit" button to rephrase your own question and put code there. – FelisCatus Nov 13 '15 at 05:57
  • @Felis-I had posted my code but it was not refelcting.Later on i realised that theres format of posting codes out here.Before marking it down,you should ask the reason for it! – Arjun Nov 13 '15 at 06:23
  • I DID NOT down-vote your question at all. Please don't blame me for the down-vote just because I've suggested improvements in comments. – FelisCatus Nov 13 '15 at 07:23

2 Answers2

0

You can use a converter:

<DataGridTextColumn Header="Amount($)" Width="*" Binding="{Binding Path = Amount}" Visibility="Binding Path = Tran_Code, Converter={StaticResource VisibilityConverter}"></DataGridTextColumn>

public class VisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string transcode = value.ToString();
                if (transcode == 1)
                    return Visibility.Hidden;                
                else
                    return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
lerner1225
  • 862
  • 7
  • 25
0

this.mydatagrid.Columns[2].Visibility = Visibility.Hidden;

you can add the index of the column to be hidden.