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
135
conditional formatting one cell with other cell value
posted

I have been browsing the forum and this simple issue has many outdated and unavailable answers. I have a nice xamdatagrid with a couple of fields: EstatusGastoId and Id. The latter has some hyperlinks to change some values. I want to show only one of the commands depending on EstatusGastoId value, I tried this:

<igDP:TextField Name="EstatusGastoId" Label="Estatus" Width="100" IsReadOnly="True" />
<igDP:TemplateField Name="Id" Label="" HorizontalContentAlignment="Center" >
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">

<TextBlock Margin ="5 0 0 0 ">
<Hyperlink Command="{Binding DataContext.RechazaGastoCommand,RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" CommandParameter="{Binding}" >
<TextBlock Text="Rechazar" TextDecorations="Underline" Foreground="Red" Visibility="{Binding EstatusGastoId,Converter={StaticResource EstatusToRechazarVisibilityConverter}}"/>
</Hyperlink>
</TextBlock >

<TextBlock Margin ="5 0 0 0 ">
<Hyperlink Command="{Binding DataContext.CancelaRechazoGastoCommand,RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" CommandParameter="{Binding}" >
<TextBlock Text="Cancela Rechazo" TextDecorations="Underline" Foreground="Blue" />

</Hyperlink>
</TextBlock >

</StackPanel>
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>

but it cannot find EstatusGastoId. I am sure it's something very silly but I cannot find any reference out there on how to do this. any suggestions?

Parents
  • 2860
    Offline posted

    Hi Enrique,

    Thank you for posting to Infragistics Community!

    What you are looking to achieve is definitely possible and could be approached in different ways.

    To start with, I believe the following topics from our documentation will be helpful:

    1. Configuring Template Field
    2. Apply Cell Value Templates Conditionally

    As the latter topic suggests, the DisplayTemplateSelector is a convenient API exposed to conditionally configure a display template.

    Furthermore, to demonstrate yet another alternative, I am attaching a small sample here, where TextBlocks are conditionally rendered within a display template with the help of a DataTrigger. Optionally, a Converter class could be used to define a more complex condition for the binding. Please, note that this is rather a general WPF implementation question, though.

    The sample also demonstrates an additional binding to a Command and defining its CanExecute method.

    In conclusion, please, check out the referenced resources and let me know if they help.

    Best regards,
    Bozhidara Pachilova
    Software Developer

Reply Children
No Data