Windows Phone 和 Silverlight ListBox.ItemTemplate
我有一个带有以下列表框的 Windows Phone 7 应用程序,每个项目都包含 2 个文本块和一个超链接按钮。
<ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Vertical">
<TextBlock/>
<TextBlock/>
<HyperlinkButton Content="[More...]" FontSize="12"HorizontalAlignment="Right" Height="30" Click="ClickEvent">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click"<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding GetCommand, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
在 ViewModel 构造函数中,我有以下代码:
GetCommand = new RelayCommand(() =>{some code}); where GetCommand is a property :
public RelayCommand GetCommand { get; private set; }
我的问题是,当我按下按钮时, GetCommand = new RelayCommand(() =>{some code});
没有执行。
我必须说,如果不将 HyperlinkButton 放置在 itemTemplate 中,则一切正常。 我使用 Galasoft mvvm light takeit - http://www.galasoft.ch/mvvm/getstarted/< /a> 我很感激任何帮助。
I have a Windows Phone 7 application with the following listbox and every item contains 2 textblocks and a HyperlinkButton.
<ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Vertical">
<TextBlock/>
<TextBlock/>
<HyperlinkButton Content="[More...]" FontSize="12"HorizontalAlignment="Right" Height="30" Click="ClickEvent">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click"<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding GetCommand, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
In the ViewModel constructor I have the following code:
GetCommand = new RelayCommand(() =>{some code}); where GetCommand is a property :
public RelayCommand GetCommand { get; private set; }
My problem is that GetCommand = new RelayCommand(() =>{some code});
is not executing when I press the button.
I must say that if dont place the HyperlinkButton insise the itemTemplate, everything works fine.
I use the Galasoft mvvm light tookit - http://www.galasoft.ch/mvvm/getstarted/
I appreciate any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您的 XAML 中有拼写错误,它应该显示为 -
从绑定表达式中删除
Mode=OneWay
后尝试代码。HTH,indyfromoz
I am guessing you have a typo in your XAML, it should read -
Try the code after removing the
Mode=OneWay
from the binding expression.HTH, indyfromoz