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中选择对应的用户 ...
随机推荐
- C#扇形的绘制与Hittest交互、图种制作
C# 扇区的绘制与交互 哪位大神的杰作,代码里有,我就不废话了.源码下载方式如下. 注:将下面的图下载后,另存为.rar就可以看到图片中隐藏的代码程序了. 图种的制作 图种的目的在于隐藏文件.使得外人 ...
- caffe-mnist别手写数字
[来自:http://www.cnblogs.com/denny402/p/5685909.html] 整个工作目录建在:/home/ubunt16041/caffe/examples/abc_mni ...
- Java 如何将String转化为Int
在 Java 中要将 String 类型转化为 int 类型时,需要使用 Integer 类中的 parseInt() 方法或者 valueOf() 方法进行转换. 例1: 1 2 3 4 5 6 S ...
- 评论Beta版本发布
1. 新蜂:俄罗斯方块 俄罗斯方块在完成了核心的游戏部分基础上增加了两个小功能,后续的内容还一些没完成,所以界面空出来很多板块,当前版本加入了下一个方块的预览功能,还加入了本地磁盘的排行榜.但是比起 ...
- css全局样式
@charset"utf-8"; *{margin:0;padding:0;} //去默认内外边距的简易写法 body,div,dl,dt,dd,ul,ol,li,h1,h2, ...
- RealTimePerformanceDemoView
using System;using System.Diagnostics;using System.Timers;using System.Windows;using System.Windows. ...
- Java里Serializable的那些事
本文为原创文章,欢迎转载,但请注明出处http://www.cnblogs.com/yexiubiao/p/5014015.html,未在文章页面明显位置给出原文连接的,将保留追究法律责任的权利. 通 ...
- 无需Try catch 的UI事件封装类
在UI处理中,经常需要进行异常处理,以便在错误发生时能够进行一些自定义的操作,比如,弹出消息框给用户,进行重试操作,记录日志等,如果能够让用户写代码时不用写try...catch,而只是关注业务逻辑的 ...
- 用javascript比较快速排序和合并排序的优劣
<script> //用来调用排列方法的类 function arr_sort(arr){ var startTime,endTime; var priv_arr = new Array; ...
- Android自动化学习笔记:获取APK包名的几种方法
---------------------------------------------------------------------------------------------------- ...