One way to chain two converts is to route it through the datacontext.<HyperLink DataContext="{Binding MyProperty, Converter={StaticResource Converter1}}"NavigateUri={Binding Converter={StaticResource Converter2}}" />That way NavigateUri will be binding to the value returned by MyProperty+Converter1, and route this through Converter2.
In my example 'Attributes' was the path to the dictionary but I was more thinking to an usage with a feature data grid.With a maptip, it should rather be 'Path=.' because the framework sets the maptip datacontext to the Attributes dictionary itself.So: NavigateUri="{Binding Path=., Converter ={StaticResource uriDictConverter}, ConverterParameter=UrlField}" The converter will get the dictionary as input value and the Url attribute as ConverterParameter.The converter should be something like (not tested): public class UriDictionaryConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { IDictionary<string, object> dict = value asIDictionary<string, object>; String urlField = parameter as String; if (dict != null) { if (dict.ContainsKey(urlField)) return Uri("http://Myserver/" + dict[urlField]); } return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
NavigateUri="{Binding Path=., Converter ={StaticResource uriDictConverter}, ConverterParameter=UrlField}"
public class UriDictionaryConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { IDictionary<string, object> dict = value asIDictionary<string, object>; String urlField = parameter as String; if (dict != null) { if (dict.ContainsKey(urlField)) return Uri("http://Myserver/" + dict[urlField]); } return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }
<xmlns:uri="clr-namespace:HVAC;assembly=HVAC"> <UserControl.Resources> <uri:UriConverter x:Name="UriConverter"/> </UserControl.Resources> ..... <HyperlinkButton x:Name="VAVuserdoc" Content="Open" DataContext="{Binding Converter={StaticResource HHVACVAVDictionaryConverter}}" NavigateUri="{Binding Converter={StaticResource UriConverter}, ConverterParameter=USERDOC}" TargetName="_blank" FontWeight="Bold" Margin="3,0,3,0"/>
Public Class UriConverter Implements IValueConverter Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert Dim path As Uri = Nothing If Not value Is Nothing Then Dim pathNameBuilder As New UriBuilder pathNameBuilder.Scheme = "http" pathNameBuilder.Host = "myserver.domain.com" pathNameBuilder.Path = "root/directory/" + value(parameter.ToString).ToString path = pathNameBuilder.Uri End If Return path End Function Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack Throw New NotImplementedException() End Function End Class
Probably not easy to chain 2 converters.
NavigateUri="{Binding Attributes, Converter ={StaticResource uriDictConverter}, ConverterParameter=UrlField}"
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.