[英]Multiple Bind in HyperLinkButton Navigate URI
I am trying to build an app for Windows Phone 7.5 , I have some textblock that I bind some values from an xml file with the following code 我正在尝试为Windows Phone 7.5构建应用程序,我有一些文本块,使用以下代码绑定了xml文件中的某些值
<TextBlock Grid.Row="2" TextWrapping="Wrap" Text="{Binding People}" Foreground="White" />
Now I want to bind in a HyperLink Button 2 binds in the link. 现在,我想绑定一个HyperLink Button 2链接中的绑定。 So I could create a facebook share.
所以我可以创建一个facebook分享。
<HyperlinkButton Grid.Row="4" Content="Share" TargetName="_blank" NavigateUri="http://www.facebook.com/sharer.php?u={Binding People}&title={Binding Title}"/>
The above code don't work can you please guide me to make it work. 以上代码不起作用,请指导我使其工作。 I have already tried some alchemies with +,"'" and other stuff but doesn't seems to work.
我已经尝试了一些带有+,“'”和其他东西的炼金术,但似乎没有用。
Thanks in advance 提前致谢
You cannot do this. 你不可以做这个。 This is not string concatination
这不是字符串连接
NavigateUri="http://www.facebook.com/sharer.php?u={Binding People}&title={Binding Title}"
What you need to do is create a converter
and pass the object that contains People
and Title
to converter
. 您需要做的是创建一个
converter
,并将包含“ People
和“ Title
的对象传递给converter
。 Then inside converter
create a URI
然后在
converter
内部创建一个URI
something like this. 这样的事情。 I am not sure about the syntax but you can get the main idea
我不确定语法,但你可以得到主要的想法
NavigateUri={Binding Converter={StaticResource YourConverter}, ConverterParameter=''{Binding YourObject}"}
Then inside converter 然后在转换器内部
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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.