Select to view content in your preferred language

How to assign a graphic attribute to a NavigateUri

636
2
03-20-2013 02:39 PM
DonFreeman
Emerging Contributor
My page has a set of fixed Hyperlink Buttons. The NavigateUri of these will change depending on the feature selected by the user. I am making the assignment like this:
 MessageBox.Show(feature.Attributes["Demographics Data"] as String);
 DemographicLink.NavigateUri = feature.Attributes["Demographics Data"] as Uri;

The messagebox shows that the URL is proper and the code runs without error. However when I click the hyperlink, nothing happens. The hyperlink is defined like this:
<HyperlinkButton x:Name="DemographicLink" NavigateUri="" TargetName="Contentframe" Content="Demographic Data" Foreground="DarkSlateBlue"/>

Can someone suggest what I have wrong?
Thanks
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
DemographicLink.NavigateUri = feature.Attributes["Demographics Data"] as Uri;

feature.Attributes["Demographics Data"] is a string and returns null after casting to Uri.

Try this instead:
DemographicLink.NavigateUri = new Uri(feature.Attributes["Demographics Data"]);
0 Kudos
DonFreeman
Emerging Contributor
Thanks Dom. I had to do it this way.
string dString = feature.Attributes["Demographics Data"] as string;
DemographicLink.NavigateUri = new Uri(dString);
0 Kudos