2012-02-20 46 views
1

我试图构建的Windows Phone 7.5的应用程序,我有一些文字块多种绑定

<TextBlock Grid.Row="2" TextWrapping="Wrap" Text="{Binding People}" Foreground="White" /> 

现在我想结合我结合一些值从XML文件用下面的代码在超链接按钮2绑定在链接中。所以我可以创建一个Facebook分享。

<HyperlinkButton Grid.Row="4" Content="Share" TargetName="_blank" NavigateUri="http://www.facebook.com/sharer.php?u={Binding People}&title={Binding Title}"/> 

上面的代码不起作用,请你指导我使它工作。我已经用+,“'”和其他东西尝试了一些炼金术,但似乎没有工作。

在此先感谢

回答

3

你不能这样做。这不是字符串concatination

NavigateUri="http://www.facebook.com/sharer.php?u={Binding People}&title={Binding Title}"

你需要做的是创建一个converter,并通过包含PeopleTitleconverter的对象。然后在converter里面创建一个URI

这样的东西。我不知道有关语法,但你可以得到的主要思想

NavigateUri={Binding Converter={StaticResource YourConverter}, ConverterParameter=''{Binding YourObject}"} 

内。然后转换

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
     { 
      if (value != null) 
      { 
       YourObject obj = (YourObject) value; 
       //create URI and return it 
      } 
     } 
+0

那是像我一样(新知识)为新手作品的地狱,我来试试。感谢提示。 – Sonamor 2012-02-20 12:33:07

+0

首先阅读有关转换器的信息 – 2012-02-20 13:09:57