在页面导航中绑定

时间:2013-01-07 19:53:19

标签: c# windows-phone-7 variables binding

我还有另一个与windows phone 7 dev的问题。我正在创建包含项目和一个文本块的列表框,这类似于链接到另一个页面。每个链接都有另一个“页面”变量值。

<TextBlock Tap="TextBlock_Tap" Foreground="#FF40AA2F" Text="View details">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonDown">
                    <ec:NavigateToPageAction TargetPage="/details.xaml?page={Binding Index}" />

                </i:EventTrigger>
            </i:Interaction.Triggers> 
</TextBlock>

但它不能与targetpage中的当前值一起使用,因为Visual Studio将其视为普通字符串。如何在页面变量中嵌入此绑定?谢谢

2 个答案:

答案 0 :(得分:1)

尝试使用StringFormat:

<ec:NavigateToPageAction TargetPage="{Binding Path=Index, StringFormat='/details.xaml?page={0}'}" />

答案 1 :(得分:0)

执行导航,而不是在触发器上,而是在文本块的MouseLeftButtonDown事件后面的代码中,并从列表框的当前选择中提取目标页面。