困扰好几个小时的问题终于解决了,本人系菜鸟,使用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. 黄聪:微信支付错误两个问题的解决:curl出错,错误码:60

    如下是运行微信支付测试代码时出错代码: Warning: curl_setopt() expects parameter 2 to be long, string given in D:\wwwroo ...

  2. Android学习笔记(十四)

    Android中的数据存储 数据持久化就是指那些内存中的瞬时数据保存到存储设备中.Android系统中主要提供了三种方式用于简单地实现 数据持久功能,即文件存储.SharedPreferences存储 ...

  3. Spark Job的提交与task本地化分析(源码阅读八)

    我们又都知道,Spark中任务的处理也要考虑数据的本地性(locality),Spark目前支持PROCESS_LOCAL(本地进程).NODE_LOCAL(本地节点).NODE_PREF.RACK_ ...

  4. css中 input的button默认原始的样子

    以往我们写css时,让一行文字垂直居中. 会设置line-height等于height比如: 当我把这个原理 放在button上时  会是这个样子的. 以下都是火狐浏览器环境 有没有发现一个现象,他们 ...

  5. [源码]String StringBuffer StringBudlider(2)StringBuffer StringBuilder源码分析

      纵骑横飞 章仕烜   昨天比较忙 今天把StringBuffer StringBulider的源码分析 献上   在讲 StringBuffer StringBuilder 之前 ,我们先看一下 ...

  6. 物料主数据MRP4中的独立/集中

    转自悲守穷庐 http://blog.itpub.net/12287/viewspace-681569/ 从按订单还是按库存来考虑. (1)独立集中为空,即又上层决定独立集中情况 (2)独立集中为1: ...

  7. css 画基本图形

    抄于http://dongtianee.sinaapp.com/demo9.html /******************************************************** ...

  8. [翻译练习]密码学1小时入门 (Everything you need to know about cryptography in 1 hour)

    原文:http://www.daemonology.net/papers/crypto1hr.pdf   [密码学简介]   很多人都误用了密码学   一般可归为三类: 1. 愚蠢 比如Google ...

  9. get application power

    1. http://blog.csdn.net/sjz_iron/article/details/8726661 http://www.16rd.com/home.php?mod=space& ...

  10. 一个.NET通用JSON解析/构建类的实现(c#)转

    转自:http://www.cnblogs.com/xfrog/archive/2010/04/07/1706754.html NET通用JSON解析/构建类的实现(c#) 在.NET Framewo ...