列表框选择已更改事件不会使用动态创建的panaroma项目触发。正在使用MVVM光框架 [英] Listbox selection changed event does not fire with a dynamically created panaroma item. MVVM light framework being used

查看:73
本文介绍了列表框选择已更改事件不会使用动态创建的panaroma项目触发。正在使用MVVM光框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个手机页面,其中包含一个panaroma控件,其中包含staticall声明的panaroma项目以及在后面的代码中动态创建的更多panaroma项目。

I have a phone page with one panaroma control with a staticall declared panaroma items and more panaroma items being created dynamically in the code behind.

   1)在xaml中声明的panaroma项绑定到视图模型A,它有一个绑定到视图模型中的属性的列表框。这个列表框的selectionchanged事件工作正常

  1 ) panaroma item declared in xaml is bound to view model A and it has a list box that is bound to a property in the view model. The selectionchanged event for this list box works just fine

2)我在代码中动态创建了其他panaroma项目,它必然会查看通过某些索引器属性公开的模型B查看模型A. 这些panaroma项目也有一个列表框..此列表框
的selectionchanged事件似乎没有触发..我尝试在galasoft light框架中使用eventtocommand行为,没有运气。后来,我把列表框的selectionchanged事件连接到代码隐藏,但没有运气。

2) I have other panaroma items being created dynamically in the code and it is bound to view model Bs which are exposed through some indexer property of view model A. These panaroma items also have a list box.. The selectionchanged event for this listbox doesn't seem to be firing .. I tried using the eventtocommand behavior in the galasoft light framework with no luck.. Later, I wired up the selectionchanged event of the listbox to the codebehind with no luck too..

因为我是wpf / xaml的新手并且通过编写wp7应用程序来学习它...我希望这是明显的我做错了......任何想法或指针。我正在尝试将一个selectionchanged事件连接到viewmodel中的relaycommand,其中
会导致页面导航显示有关所选项目的更多详细信息。 为什么selectchanged事件没有被触发以及如何调试问题....

Since I am new to wpf/xaml and learning it the hardway through writing a wp7 app... i am hoping it is something obvious i am doing wrong.. Any ideas or pointers. I am trying to wire up a selectionchanged event to a relaycommand in the viewmodel which should result in a page navigation that shows more details about the selected item.  Why doesn't the selectionchanged event get fired and how to go about debugging the problem....

 

这是资源在xaml中定义样式的部分

Here is the resources section in the xaml where the style is being defined

  < phone:PhoneApplicationPage.Resources>

        < Style x:Key =" PanoramaItemStyle" TargetType =" ContentControl">

            < setter属性= QUOT;模板">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < Setter.Value>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP; < ControlTemplate中的TargetType = QUOT; ContentControl中">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <网格和GT;

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < controls:PanoramaItem x:Name =" ItemLocationPanoramaItem"头= QUOT; {结合标签名}">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <! - <的StackPanel> - >

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <列表框&NBSP; ItemsSource =" {Binding ItemLocators}"
Height =" 496" SelectedItem =" {Binding SelectedItemLocation,Mode = TwoWay}"的SelectionChanged = QUOT; ItemLocatorsList_SelectionChanged" >

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; !< - <自定义:Interaction.Triggers>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;
将自定义:EventTrigger事件名称= QUOT;的SelectionChanged">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< GalaSoft_MvvmLight_Command:EventToCommand x:Name =" SelectionChangedEvent" Command =" {Binding ElementName = ItemLocationPanoramaItem,Path = DataContext.GoToEditItemLocatorCommand}" PassEventArgsToCommand = QUOT;真" />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;
将/自定义:EventTrigger>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /自定义:Interaction.Triggers> - >

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < ListBox.ItemsPanel>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBS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;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< StackPanel Orientation =" Horizo​​ntal"保证金=" 0,0,0,17">

               &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
将StackPanel的宽度=" 311">

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
< TextBlock Text =" {Binding Item.Name}" TextWrapping = QUOT;包覆与QUOT;风格= QUOT; {StaticResource的PhoneTextLargeStyle}" />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&N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&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; <! - < / StackPanel的> - >

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /控制:PanoramaItem>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < ContentPresenter />

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP; < /网格>

&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP ; < / ControlTemplate>&
                < /Setter.Value>

            < / Setter>&
            < Setter Property =" Foreground"值="白色"/>

        < /样式和GT;&NBSP;

    < / phone:PhoneApplicationPage.Resources>

  <phone:PhoneApplicationPage.Resources>
        <Style x:Key="PanoramaItemStyle" TargetType="ContentControl">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ContentControl">
                        <Grid>
                            <controls:PanoramaItem x:Name="ItemLocationPanoramaItem" Header="{Binding TagName}">
                                <!--<StackPanel >-->
                                    <ListBox  ItemsSource="{Binding ItemLocators}" Height="496" SelectedItem="{Binding SelectedItemLocation, Mode=TwoWay}" SelectionChanged="ItemLocatorsList_SelectionChanged" >
                                        <!--<Custom:Interaction.Triggers>
                                            <Custom:EventTrigger EventName="SelectionChanged">
                                                <GalaSoft_MvvmLight_Command:EventToCommand x:Name="SelectionChangedEvent" Command="{Binding ElementName=ItemLocationPanoramaItem, Path=DataContext.GoToEditItemLocatorCommand}" PassEventArgsToCommand="True"/>
                                            </Custom:EventTrigger>
                                        </Custom:Interaction.Triggers>-->
                                        <ListBox.ItemsPanel>
                                            <ItemsPanelTemplate >
                                                <StackPanel Orientation="Vertical"  ScrollViewer.VerticalScrollBarVisibility="Auto" />
                                            </ItemsPanelTemplate>
                                        </ListBox.ItemsPanel>
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <StackPanel>
                                                        <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                                                            <StackPanel Width="311">
                                                                <TextBlock Text="{Binding Item.Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
                                                                <TextBlock Text="{Binding Location.Description}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/>
                                                            </StackPanel>
                                                        </StackPanel>
                                                </StackPanel>
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                    </ListBox>
                                <!--</StackPanel>-->
                            </controls:PanoramaItem>
                            <ContentPresenter/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="Foreground" Value="White"/>
        </Style> 
    </phone:PhoneApplicationPage.Resources>

 

以下是页面背后代码中的部分代码

Here is the partial code in the code behind of the page

  public partial class LocationGroups : PhoneApplicationPage
    {
        private LocationGroupsViewModel viewModel = null;
 
        public LocationGroups()
        {
            InitializeComponent(); 
            LocationGroupsPanaroma.DefaultItem = LocationGroupsPanaroma.Items[0];
            viewModel = this.DataContext as LocationGroupsViewModel;
            CreateDynamicPanaromaItems();
        }
         
 
        private void CreateDynamicPanaromaItems()
        {
            foreach (Model.LocationGroup group in viewModel.LocationGroups)
            {
                if (group.TotalItems > 0)
                {
                    PanoramaItem pi = new PanoramaItem();
                    pi.Header = group.Name;
                    pi.Orientation = System.Windows.Controls.Orientation.Horizontal;
                    ItemLocationListViewModel itemLocationViewModel = viewModel[group.LocationGroupId];
                    pi.DataContext = itemLocationViewModel;
                    pi.Style = Resources["PanoramaItemStyle"as Style; 
                    LocationGroupsPanaroma.Items.Add(pi);
                }
            }
 
        }

 

推荐答案

嗨SivaS,

Hi SivaS,

我仔细阅读了你的帖子,我发现它不像WP / Windows Phone7那样的WPF问题,对于我对Windows Phone7的有限知识感到抱歉,我建议你可以在
上发布你的问题 Windows Phone 7 论坛,了解selectionchanged事件未触发的原因, &NBSP;论坛链接是:

I read your post carefully, and I find it is not a WPF issue more like SL/Windows Phone7, sorry for my limited knowledge on Windows Phone7, I suggest that you could post your issue on Windows Phone 7 forum to get the reason why selectionchanged event does not fire,  that forum link is:

http:// social。 msdn.microsoft.com/Forums/en-US/windowsphone7series/threads

感谢您的理解。

 

祝你好运,


这篇关于列表框选择已更改事件不会使用动态创建的panaroma项目触发。正在使用MVVM光框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆