Select to view content in your preferred language

Hyperlink in Attributes

856
2
03-25-2013 02:18 AM
TolgaBakirman
Deactivated User
Hi,

I have a point feature in my application. I'm able to identify by on-click.
I have an attribute that is a link to website (e.g. http://www.*****.com)
But this doesnt appear as a clickable link. It appears as text.

I tried using href (<a href="http://www.*****.com">Click Here!</a>. It didnt work.
Neither typing "http://www.****.com" or http://www.***.com

[ATTACH=CONFIG]22924[/ATTACH]

Any suggestions?

Thanks,
0 Kudos
2 Replies
Matrix_Solutions_Inc_Geomatics
Regular Contributor
The data template by default is a textblock. You will need to modify it to have a textblock for normal values and a hyperlink button for hyperlinks.

<data:DataGridTemplateColumn.CellTemplate>
         <DataTemplate>
               <Grid>
                     <TextBlock Text="{Binding Value}" FontSize="11" Margin="3,2,3,2" HorizontalAlignment="Left"  TextAlignment="left" Visibility="{Binding  Converter={StaticResource LinkCollapsedConverter}}"/>
                      <HyperlinkButton Content="Click for more info..." FontSize="11" Margin="3,2,3,2" HorizontalAlignment="Left"  NavigateUri="{Binding Value}" TargetName="_blank" Visibility="{Binding  Converter={StaticResource LinkVisibilityConverter}}"/>
                 </Grid>
            </DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>


Then create two converters, one for the textblock and another for the hyperlink button. When one is converter evaluates true it will show the element associated with it, the other will be false and hide the element associated with it.

    public class LinkCollapsedConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return Visibility.Visible;
            }
            KeyValuePair<string, object> _value = (KeyValuePair<string, object>) value;
            if (_value.Value == null)
            {
                return Visibility.Visible;
            }
            if (_value.Value.ToString().StartsWith("http"))
            {
                return Visibility.Collapsed;
            }
            return Visibility.Visible;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
0 Kudos
TolgaBakirman
Deactivated User
Thank you for your answer.

But i tried using maptips instead as explained here : http://forums.arcgis.com/threads/82438-Can-you-put-a-hyperlink-in-a-maptip

Regards,
0 Kudos