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
145
Dynamically show hyperlink in xamdatagrid
posted

I used a CellValuePresenter to display hyperlinks in the grid successfully after following examples in this forum.

<infra:XamDataGrid.Resources>

<Style TargetType="{x:Type infra:CellValuePresenter}" x:Key="hyperlinkCell">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type infra:CellValuePresenter}">
<TextBlock Margin="{TemplateBinding Padding}">
<Hyperlink NavigateUri="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"/>
</Hyperlink>
</TextBlock>

</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</infra:XamDataGrid.Resources>

<infra:FieldLayout.Fields>
<infra:Field
Name="CoverageName"
Width="280"
Label="{Localize coverageName}">
<infra:Field.Settings>
<infra:FieldSettings
AllowEdit="False"
LabelClickAction="Nothing"
KeyboardNavigation.IsTabStop="False"
CellValuePresenterStyle="{StaticResource hyperlinkCell}">
</infra:FieldSettings>
</infra:Field.Settings>
</infra:Field>

With this all my coverages are hyperlinked now in the xamdatagrid.

I need to optionally (based on field value in this case CoverageName) show the hyperlink so some values will be hyperlinked and some will not in the xamdatagrid that is using the cellvaluepresenter.The coveragenames are dynamically filled in the xamdatagrid. Is this possible? Any examples would be helpful.