toolkit:Accordion DataTemplate ListBox TextBlock Interaction.Triggers
困扰好几个小时的问题终于解决了,本人系菜鸟,使用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的更多相关文章
- Windows phone 之Interaction.Triggers的使用
两个步骤:1.添加以下两个程序集System.Windows.InteractivityMicrosoft.Expression.Interactions 2.添加xmlns:i="clr- ...
- Interaction triggers in WPF
Interaction Class - static class that owns the Triggers and Behaviors attached properties. Handles p ...
- NavigateToPageAction打开新页面
首先要加上两个命名空间 分别为: xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.In ...
- wpf Datagrid 的全选
在我的一个datagrid的一列中需要全选框,所以我在样式中是这样写的: <DataGridTemplateColumn.Header> <CheckBox> <i:In ...
- WPF ListBox的DataTemplate例子
<ListBox Name="lbLogInfo"> <ListBox.ItemTemplate> <DataTemplate> <Gri ...
- 【WPF】ListBox使用DataTemplate 以及默认选中第一项Item
ListBox中DataTemplate的用法如下 . <ListBox x:Name="areaLB" ItemsSource="{Binding AreaNum ...
- Windows Phone MultiBinding :Cimbalino Toolkit
在WPF和WIN8中是支持MultiBinding 这个有啥用呢,引用下MSDN的例子http://msdn.microsoft.com/en-us/library/system.windows.da ...
- WPF学习笔记:获取ListBox的选中项
有代码有J8: UI <UserControl x:Class="UnitViews.UserListUV" xmlns="http://schemas.micro ...
- WPF中TabControl控件和ListBox控件的简单应用(MVVM)
本文主要实现下图所示的应用场景: 对于Class1页,会显示用户的age和address属性,对于Class2页,会显示用户的age,address和sex属性.在左边的ListBox中选择对应的用户 ...
随机推荐
- JVM--标记-清除算法Mark-Sweep
前言 垃圾自动回收机制的出现使编程更加的简单,使得我们不需要再去考虑内存分配和释放的问题,而是更加的专注在我们产品功能的实现上.但是我们还是需要花时间去了解下垃圾收集机制是怎么工作的,以便后面能够更好 ...
- 建立一套完整的Maven依赖工程步骤,包含WEB工程
建立Java Web工程:File -> New -> other… -> Web -> Dynamic Web Project,abs-inf选中该工程右键 -> co ...
- 安装中文版cacti监控华为交换机流量并实现95计费
摘要:一. 装置yum源: 以网易yum源为例 1. 下载repo文件 下载地点:http://mirrors.163.com/.help/CentOS6-Base-163.repo 2.备份并调换体 ...
- 使用JavaScript的Join方法
在本例中,我们将创建一个数组,然后把它的所有元素放入一个字符串: <script type="text/javascript"> var arr = new Array ...
- mybatis的动态sql及模糊查询
1.动态sql 使用类似于jstl表达式来实现 2.模糊查找 用一个对象来封装条件 步骤: 1)新建一个条件实体 package com.hy.mybatis.entity; public class ...
- delphi 串口 关于RS485总线通信协议开发注意事项
http://blog.csdn.net/shjhuang/article/details/9426739 关于RS485总线通信协议开发注意事项 1 前言 近段时间发现我们系统在进行设备 ...
- 反转链表,时间复杂度O(n),空间复杂度O(1)
原理:使用三个指针,p,q指向交换的元素,r指向后续元素 代码如下: class Node{ int data; Node next; Node(int data){ this.data=data; ...
- IIS 平台NET无后缀名伪静态实现办法
使用URLRewrite重写链接地址时,当无后缀时,总是找不到文件,不能使用.例如:http://shop.iccoo.cn/7648/ 无后缀形式(当然这个是可以的啦,只是看下链接形式) 当有后缀时 ...
- AX 2012 两种lookup 的显示方式
第一种:只能单选的lookup: 代码: public void BusinessUnitLookup(FormStringControl _formstrcontroll) { //OMOperat ...
- 如何解決 Homebrew Update 失敗?
相信許多用 MAC 系統的程式設計師.工程師們都有用 Homebrew 這個超好用的 Open Source 套件管理程式吧? 如果沒有的話,你可以透過以下的指令安裝: ruby -e "$ ...