Try this
<DataTrigger Binding="{Binding Path=DataItem.ConfigFileType}" Value="CONFIG_FILE">
In binding instead ConfigFileType it should be DataItem.ConfigFileType. I hope this will help.
Frage
i have an enum
public enum ConfigFileTypes
{
NONE,
CONFIG_FILE
}
i want to use xamdatagrid, every time the enum value will be Config_file i want to show a browse button, for non i want to show nothing, in the future more buttons or options will be added.
i was trying to use xam data grid i was able to get the button created. showing the type of the enum as the button content.
<igDP:Field Name="ConfigFileType" Label="Config File">
<igDP:Field.Settings>
<igDP:FieldSettings >
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button Content="{Binding DataItem.ConfigFileType}"></Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
now i'm trying to use data trigger in order to control the visibility of the button (is that the correct way to do this?)
<igDP:Field Name="ConfigFileType" Label="Config File">
<igDP:Field.Settings>
<igDP:FieldSettings >
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<DataTrigger Binding="{Binding Path=ConfigFileType}" Value="CONFIG_FILE">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button Content="{Binding DataItem.ConfigFileType}"></Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
i can't seem to get the data trigger working
Lösung
Try this
<DataTrigger Binding="{Binding Path=DataItem.ConfigFileType}" Value="CONFIG_FILE">
In binding instead ConfigFileType it should be DataItem.ConfigFileType. I hope this will help.
Andere Tipps
<igDP:Field Name="ConfigFileType" Label="Config File">
<igDP:Field.Settings>
<igDP:FieldSettings >
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<Button Content="{Binding DataItem.ConfigFileType}"></Button>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding DataItem.ConfigFileType}" Value="NONE">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding DataItem.ConfigFileType}" Value="CONFIG_FILE">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
thanks to ethicallogics answer i found the proper way to do this.