Select to view content in your preferred language

Hyperlink Button

912
8
04-25-2011 06:05 AM
JayKappy
Frequent Contributor
I have a hyperlink button working

<HyperlinkButton Content="Go To Website" Foreground="White" NavigateUri="http://www.ci.mn.us/content/141/195/default.aspx" TargetName="_blank"> </HyperlinkButton>


I am now trying to bind it to a Field Value that has the URL in it....but no go....any thoughts?

<HyperlinkButton Content="Open PDF" VerticalAlignment="Center" Foreground="White" NavigateUri="{Binding [MAPITVALUE]}" TargetName="_blank" > </HyperlinkButton>
0 Kudos
8 Replies
JayKappy
Frequent Contributor
Think I got it....added Attributes

NavigateUri="{Binding Attributes[MAPITVALUE]}"

Yep that was it.....
0 Kudos
JianChen
Regular Contributor
Think I got it....added Attributes 

NavigateUri="{Binding   Attributes[MAPITVALUE]}" 

Yep that was it.....


Same need here; I need to bind a field [Link] which has URL in it. I tried what you suggested but it doesn't work for me. Did I miss anything? BTW, I'm using ArcGIS API for Silverlight 2.4. Here is my code:

<HyperlinkButton TargetName="_blank" Content="Open" NavigateUri="{Binding Attributes[Link]} />
0 Kudos
JianChen
Regular Contributor
More interestingly I found that only very fiew fields of the layer can be passed via binding. There are 26 fields in total and most of them are esriFieldTypeString, I used field binding to pass the value to a HyperlinkButton as content (code below), only very few show their attribute value, others just show empty space. Unfortunately the field has URL, "Link", is one of the field cannot pass the value. I guess this might be the reason that binding for NavigateUri doesn't work. Am I right? But why?

<HyperlinkButton Content="{Binding [Link]}"  NavigateUri="{Binding Attributes[Link]}" />


I understand that the DataContext for a graphic is a dictionary. When I debugging it, I can find the dictionary only has 6 keys. The data source for the layer is a geodatabase feature class.
MessageBox.Show(args.Graphic.Attributes.Keys.Count.ToString());


Is there anybody could tell me the rule of binding fields in a feature layer, like in which situation, the binding won't success? Thanks.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
In the maptip case, the datacontext is a dictionary of attributes, so the binding should be  NavigateUri="{Binding [Link]}" instead of  NavigateUri="{Binding Attributes[Link]}"

That being said, if even ="{Binding [Link]}"  is null, it might happen that your link attribute is not returned by the server.
Check that this attributes is listed in the 'OutFields' property of your feature layer.
0 Kudos
JianChen
Regular Contributor
In the maptip case, the datacontext is a dictionary of attributes, so the binding should be  NavigateUri="{Binding [Link]}" instead of  NavigateUri="{Binding Attributes[Link]}"

That being said, if even ="{Binding [Link]}"  is null, it might happen that your link attribute is not returned by the server.
Check that this attributes is listed in the 'OutFields' property of your feature layer.


Thanks Dominique! NavigateUri="{Binding [Link]}" won't work either and the 'OutFields' has been set as * so every field should return. As I mentioned above, majority of the layer's attributes are not returned as I tested by different field names. In the code here, I tried to pass the value of [Link] field (esriFieldTypeString) as content of the HyperlinkButton but get nothing. I think I need to figure out why fields like [Link] aren't returned by the server. Any clue?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Any clue?


If your 'OutField' is set to '*', all published fields shoud be returned. Check that your fields have not be hidden before publishing the service.

Otherwise, use fiddler to look at the request sent to the server. This might give a clue.
0 Kudos
JianChen
Regular Contributor
If your 'OutField' is set to '*', all published fields shoud be returned. Check that your fields have not be hidden before publishing the service.

Otherwise, use fiddler to look at the request sent to the server. This might give a clue.


I'm pretty sure that no field is hidden in the source. I don't think it is some issue with the service either because all the fields are able to display in a feature datagrid. I just don't know why not all fields can be passed to the DataContext of MapTip, the Dictionary in this case. I said earlier, there are 26 fields in total but the dictionary only have 6 keys. Is it possible a bug somewhere? Thanks.
0 Kudos
JianChen
Regular Contributor
If your 'OutField' is set to '*', all published fields shoud be returned. Check that your fields have not be hidden before publishing the service.

Otherwise, use fiddler to look at the request sent to the server. This might give a clue.


Hey Dominique, you are right! I made a mistake; the sentence to set 'OutField' to '*' was commented out and I just selected six columns by field name for other purpose. Thanks a lot!
0 Kudos