困扰好几个小时的问题终于解决了,本人系菜鸟,使用MVVM设计模式,绑定DataTemplate的Command,需要使用

DataContent的资源,否则无法触发ICommand ClickChildMenu

下面是关键代码:

<TextBlock   Text="{Binding Title}" FontSize="12" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp" >
<i:InvokeCommandAction
Command="{Binding ElementName=LayoutRoot,
Path=DataContext.ClickChildMenu}"
CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
<toolkit:Accordion x:Name="theList" SelectionMode="ZeroOrOne"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="12"  ItemsSource="{Binding Catalog}">
<toolkit:Accordion.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding CatalogName}" FontSize="12" />
</StackPanel>
</DataTemplate>
</toolkit:Accordion.ItemTemplate>
<toolkit:Accordion.ContentTemplate>
<DataTemplate>
<ListBox x:Name="mListBox" ItemsSource="{Binding ChildMenus}" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Title}" FontSize="12" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp" >
<i:InvokeCommandAction
Command="{Binding Source={StaticResource vm},
Path=ClickChildMenu}"
CommandParameter="{Binding}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</DataTemplate>
</ListBox.ItemTemplate> </ListBox>
</DataTemplate>
</toolkit:Accordion.ContentTemplate>
</toolkit:Accordion>

toolkit:Accordion DataTemplate ListBox TextBlock Interaction.Triggers的更多相关文章

  1. Windows phone 之Interaction.Triggers的使用

    两个步骤:1.添加以下两个程序集System.Windows.InteractivityMicrosoft.Expression.Interactions 2.添加xmlns:i="clr- ...

  2. Interaction triggers in WPF

    Interaction Class - static class that owns the Triggers and Behaviors attached properties. Handles p ...

  3. NavigateToPageAction打开新页面

    首先要加上两个命名空间 分别为: xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.In ...

  4. wpf Datagrid 的全选

    在我的一个datagrid的一列中需要全选框,所以我在样式中是这样写的: <DataGridTemplateColumn.Header> <CheckBox> <i:In ...

  5. WPF ListBox的DataTemplate例子

    <ListBox Name="lbLogInfo"> <ListBox.ItemTemplate> <DataTemplate> <Gri ...

  6. 【WPF】ListBox使用DataTemplate 以及默认选中第一项Item

    ListBox中DataTemplate的用法如下 . <ListBox x:Name="areaLB" ItemsSource="{Binding AreaNum ...

  7. Windows Phone MultiBinding :Cimbalino Toolkit

    在WPF和WIN8中是支持MultiBinding 这个有啥用呢,引用下MSDN的例子http://msdn.microsoft.com/en-us/library/system.windows.da ...

  8. WPF学习笔记:获取ListBox的选中项

    有代码有J8: UI <UserControl x:Class="UnitViews.UserListUV" xmlns="http://schemas.micro ...

  9. WPF中TabControl控件和ListBox控件的简单应用(MVVM)

    本文主要实现下图所示的应用场景: 对于Class1页,会显示用户的age和address属性,对于Class2页,会显示用户的age,address和sex属性.在左边的ListBox中选择对应的用户 ...

随机推荐

  1. 解决未能加载文件或程序集“Newtonsoft.Json ...."或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)

    今天遇到了一个比较坑的问题,琢磨了好久... 因为需要引用一个第三方的类库,三方的类库引用的是Newtonsoft.Json.dll 版本7.0.0而我的项目中引用的是Newtonsoft.Json. ...

  2. Tomcat启动报错 Could not reserve enough space for object heap

    报错信息: Error occurred during initialization of VM Could not reserve enough space for object heap Coul ...

  3. DNS错误 事件4000 4013

    DNS 错误事件4000 4013,无法创建活动目录本身的区域 WINDOWS 2003 DNS服务器无法解析 错误ID 4000 DNS 服务器无法打开 Active Directory.这台 DN ...

  4. EventBus--介绍

    注意: 1,post()方法里面的类型和onEvent()中的类型要一致., 2,订阅者对象中 必须有 onEvent 的 public 方法     ---public void onEvent(O ...

  5. C#通过属性名称获取(读取)属性值的方法 z

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Prop ...

  6. step by step install Caffe

    Caffe + Ubuntu 14.04 + CUDA 8 + cudnn 8.0+Ananconda3+opencv3.0.0 //由于本人使用的是英文版ubuntu,没装汉语输入法,暂时就用蹩脚的 ...

  7. 01-C#入门(函数重载、委托)

    函数的重载 相对委托,是比较好理解的. 涉及一个概念:函数签名.函数签名包括函数的名称和参数,而函数重载:就是使用相同的名称和不同的参数(参数类型.传递方式[传值或引用])来实现的.而不能声明相同的函 ...

  8. SignalR 2.0 初次使用说明

    如何使用SignalR 2.0 一:首先通过Nuget安装SignalR 2.0 [本人使用的时候最新版本为2.0]2.0与之前1.X有部分命名空间和配置不同请注意 二:建一个专门的类库用来负责Sig ...

  9. C++与零值比较

    1.布尔值与零值的比较 if(flag)//if为真 if(!flag)//if为假 其它都为不良风格: if (flag == TRUE) ) if (flag == FALSE) ) 2.整形值与 ...

  10. 安装MySQL5.7

    安装方式:绿色安装(使用压缩文件) 文件版本:MySQL Community Server 5.7.13(x86 &x64) 大部分过程同<安装MySQL5.5>,本篇只写不同部分 ...