欢迎来到Doc100.Net免费学习资源知识分享平台!
您的位置:首页 > 程序异常 >

wp8中listbox的selectionchanged事件绑定command有关问题,

更新时间: 2014-01-05 02:38:27 责任编辑: Author_N1

 

WP8中ListBox的SelectionChanged事件绑定Command问题,求助,在线等
我在WP8中使用MVVMLight框架 4.1.27.22645

在一个ListBox的SelectionChanged事件中绑定一个Command,在ViewModel中没有触发,在线求助。

XAML代码:
<ListBox x:Name="lstProvinces"
                         ItemTemplate="{StaticResource dtItemTemplate}"
                         ItemsSource="{Binding Provinces}">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <toolkit:WrapPanel />
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <cmd:EventToCommand Command="{Binding ProvinceSelectedChangedCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem, ElementName=lstProvinces}" />
                            <!--  CommandParameter="{Binding SelectedItem, ElementName=lstProvinces}"  -->
                            <!--  <i:InvokeCommandAction Command="{Binding ProvinceSelectedChangedCommand}" CommandParameter="ddd" />  -->
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ListBox>


ViewModel中的代码
        private RelayCommand<ProvinceModel> provinceSelectedChangedCommand;

        /// <summary>
        /// Gets the ProvinceSelectedChangedCommand.
        /// </summary>
        public RelayCommand<ProvinceModel> ProvinceSelectedChangedCommand
        {
            get
            {
                return provinceSelectedChangedCommand
                    ?? (provinceSelectedChangedCommand = new RelayCommand<ProvinceModel>(
                                          (province) =>
                                          {
                                              SelectedProvince = province;

                                              //获取当前省份下的城市信息
                                              if (province != null)
                                              {
上一篇:上一篇
下一篇:下一篇

 

随机推荐程序问答结果

 

 

如对文章有任何疑问请提交到问题反馈,或者您对内容不满意,请您反馈给我们DOC100.NET论坛发贴求解。
DOC100.NET资源网,机器学习分类整理更新日期::2014-01-05 02:38:27
如需转载,请注明文章出处和来源网址:http://www.doc100.net/bugs/t/12480/
本文WWW.DOC100.NET DOC100.NET版权所有。