C# 页面导航中的绑定

C# 页面导航中的绑定,c#,windows-phone-7,variables,binding,C#,Windows Phone 7,Variables,Binding,我对WindowsPhone7dev还有一个问题。我正在创建包含项目和一个文本块的列表框,这类似于指向另一个页面的链接。每个链接将有另一个“页面”变量值 <TextBlock Tap="TextBlock_Tap" Foreground="#FF40AA2F" Text="View details"> <i:Interaction.Triggers> <i:EventTrigger EventName="Mou

我对WindowsPhone7dev还有一个问题。我正在创建包含项目和一个文本块的列表框,这类似于指向另一个页面的链接。每个链接将有另一个“页面”变量值

<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中的当前值,因为VisualStudio将其视为普通字符串。如何在页面变量中嵌入此绑定?感谢您

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

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

尝试使用StringFormat:

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

尝试使用StringFormat:

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


debugger说,代替零的是错误:“预期”。而在单词“page”后面的位置应为“}”。怎么了?你的想法很好,但我不知道如何让它起作用。@ukaszWróblewski你能试着用引号括住StringFormat参数吗
TargetPage=“{Binding Path=Index,StringFormat='/details.xaml?page={0}}”
我以代码隐藏的方式解决了这个问题。这是TextBlock_点击:Person数据=(发送者为TextBlock)。DataContext为Person;ListBoxItem PresseItem=this.listBox.ItemContainerGenerator.ContainerFromItem(数据)作为ListBoxItem;如果(pressedItem!=null){MessageBox.Show(data.Index);}它以XAML的方式执行我想要的操作。但谢谢你们:)调试器说代替零的是错误:“预期”。而在单词“page”后面的位置应为“}”。怎么了?你的想法很好,但我不知道如何让它起作用。@ukaszWróblewski你能试着用引号括住StringFormat参数吗
TargetPage=“{Binding Path=Index,StringFormat='/details.xaml?page={0}}”
我以代码隐藏的方式解决了这个问题。这是TextBlock_点击:Person数据=(发送者为TextBlock)。DataContext为Person;ListBoxItem PresseItem=this.listBox.ItemContainerGenerator.ContainerFromItem(数据)作为ListBoxItem;如果(pressedItem!=null){MessageBox.Show(data.Index);}它以XAML的方式执行我想要的操作。但谢谢你们:)