Silverlight,Caliburn,Actions和DataGrids

Silverlight,Caliburn,Actions和DataGrids,第1张

概述任何人都知道Caliburn或Caliburn Micro框架示例的良好代码示例,用于说明使用DataGrid项目的路由 *** 作? 此示例将 *** 作附加到datagrid中的每一行.该 *** 作在viewmodel上处理,viewmodel是整个视图的datacontext.这是用Micro构建的,但语法是一样的.这不使用基于约定的数据绑定. 该观点的相关部分是: <sdk:DataGrid ItemsSour 任何人都知道Caliburn或Caliburn Micro框架示例的良好代码示例,用于说明使用DataGrID项目的路由 *** 作?解决方法 此示例将 *** 作附加到datagrID中的每一行.该 *** 作在viewmodel上处理,viewmodel是整个视图的datacontext.这是用Micro构建的,但语法是一样的.这不使用基于约定的数据绑定.

该观点的相关部分是:

<sdk:DataGrID ItemsSource="{Binding Source}"                autoGenerateColumns="False">    <sdk:DataGrID.Columns>        <sdk:DataGrIDTemplateColumn header="Action">            <sdk:DataGrIDTemplateColumn.CellTemplate>                <DataTemplate>                    <button Content="Do!"                            cm:Message.Attach="Remove($dataContext)" />                </DataTemplate>            </sdk:DataGrIDTemplateColumn.CellTemplate>        </sdk:DataGrIDTemplateColumn>        <sdk:DataGrIDTextColumn Binding="{Binding Text}" />                        <sdk:DataGrIDTextColumn Binding="{Binding More}" />                        <sdk:DataGrIDTextColumn Binding="{Binding Stuff}" />    </sdk:DataGrID.Columns></sdk:DataGrID>

相应的viewmodel看起来像这样:

public class Shellviewmodel : IShell{    public Shellviewmodel()    {        Source = new ObservableCollection<MyRow>(            new[]                {                    new MyRow {Text = "A1",More = "B",Stuff = "C"},new MyRow {Text = "A2",new MyRow {Text = "A3",new MyRow {Text = "A4",new MyRow {Text = "A5",}            );    }    public voID Remove(MyRow row)    {        Source.Remove(row);    }    public ObservableCollection<MyRow> Source { get; set; }}public class MyRow{    public string Text { get; set; }    public string More { get; set; }    public string Stuff { get; set; }}

这里讨论特殊参数$dataContext:
http://caliburn.codeplex.com/wikipage?title=Parameters&referringTitle=Documentation

总结

以上是内存溢出为你收集整理的Silverlight,Caliburn,Actions和DataGrids全部内容,希望文章能够帮你解决Silverlight,Caliburn,Actions和DataGrids所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1002748.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存