动态将按钮添加到Grid MVVM Arch. [英] Dynamically adding Buttons to Grid MVVM Arch.

查看:124
本文介绍了动态将按钮添加到Grid MVVM Arch.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个包含Telerik报告的项目.
数据库包含这些报告的名称和描述
当我单击这些按钮时,此数据已绑定到包含那么多报告(按钮)的视图.
***当我在数据库中添加新记录时,我想在视图上添加新按钮??
我该如何动态地进行呢?**

I am working on a project containing Telerik reporting.
Database consist Names and Description of these reports
This data is binded to View containing That many reports (Buttons) when i click these buttons respective report is opened
*** When i add new record in DB i want to add new button on View ??
How can i do it dynamically??**

推荐答案

你好
如果您可以控制从数据库中获取报告元数据"(名称+描述),则只需创建包含这些属性的类即可.我们称之为"ReportMetaData".

创建一个属性ObservableCollection< ReportMetaData>并将报表元数据行添加到该集合中.我们称其为"ReportItems".

然后,获取应该包含按钮的项目控件以及对"ReportItems"集合的绑定.然后创建一个"ItemTemplate"来定义按钮.

希望对您有所帮助:-)
Hello
If you have control of getting the reports "metadata" (Name + Description) from the database, you can simply create class containing these as properties. Let''s call it "ReportMetaData".

Create a property ObservableCollection<ReportMetaData> and add the report metadata rows to that collection. Let''s call that "ReportItems".

Then get the item control that should hold the buttons and a Binding to the "ReportItems" collection. Then create an "ItemTemplate" to define the buttons.

Hope it helps :-)


这篇关于动态将按钮添加到Grid MVVM Arch.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆