我们计划在 Dynamics 2011 中使用 Silverlight MVVM 应用程序来实现一些自定义功能。我们还希望 Dynamics 和 Silverlight 模块的整个应用程序具有一致的外观。这就是我们创建 Web 资源来在 CRM 内托管此 Silverlight 应用程序的原因。
现在的问题是我们需要在 Ribbon 中创建“保存”、“编辑”等按钮,而这些按钮的行为又类似于 Silverlight 模块中的按钮。以下是重要问题
我们能否在功能区中创建此类按钮来访问使用“Web 资源”托管的 Silverlight 应用程序的视图模型内的方法。这些方法还必须访问用户在 Silverlight 视图中所做的数据更改。
-
有没有其他更好的方法来处理这种情况
谢谢,
Nilesh
We are planning to use Silverlight MVVM application in Dynamics 2011 for few custom features. We also want to have consistent looks for whole application for both Dynamics and Silverlight modules. That’s why we are creating web resource to host this Silverlight application inside CRM.
Now problem is we need to create “Save”, “Edit” etc buttons in Ribbon, which in-turn behaves like buttons inside Silverlight module. Following are important questions
-
Can we create such buttons in Ribbon to access methods inside View Model of Silverlight application hosted using “Web resource”. These methods will also have to access data changes done by user in Silverlight Views.
-
Is there any other better way to handle such situation
Thanks,
Nilesh
发布评论
评论(1)
最后,我通过单击功能区按钮成功调用了 Silverlight 应用程序的 C# 代码中的函数。
这是最终输出的屏幕截图。
这是 PoC 正在做的
以下是创建 PoC 的详细信息
通过编辑站点地图 XML 为此 PoC 创建了新区域和子区域。以下是在customizations.xml 中添加的XML。
在应用程序功能区中添加了自定义按钮。这是功能区的更新 XML
序列=“101”>
创建了 Silverlight 应用程序。这是重要的 C# 代码。
这是重要的 HTML 代码。
托管 Silverlight 应用程序。为此,我们需要创建两个 Web 资源 - 一个用于托管 HTML,第二个用于 XAP。
又创建了一项 Web 资源来托管 JavaScript 函数。 IE 8 中的开发人员工具 (F12) 帮助我在 HTML DOM 中找到 Silverlight 对象 (SLFromJS) 的确切位置。这是 JavaScript –
我的 CRM 解决方案现在如下所示
感谢我提到的以下博客文章。
http://www.a2zmenu.com/Blogs/ Silverlight/从 JavaScript.aspx 调用 Silverlight-Method-from-JavaScript.aspx
访问 iframe 中的表单
Finally I’ve successfully called the function inside C# code of Silverlight application from Ribbon button click.
Here is the screenshot of final output.
Here is what PoC is doing
Here are the details to create the PoC
Created new Area and Sub-Area for this PoC by editing Site Map XML. Here is the XML added in customizations.xml.
Added custom button in Application Ribbon. Here is the updated XML for Ribbon
Sequence="101">
Created Silverlight Application. Here is important C# code.
Here is important HTML code.
Hosted Silverlight Application in CRM. For this we need to create two web resources – one to host HTML and second for XAP.
Created one more web resource to host JavaScript function. Developer tools (F12) in IE 8 helped me to find exact location of my Silverlight Object (SLFromJS) in HTML DOM. Here is the JavaScript –
My CRM solution looks like following now
Thanks to following blog posts which I referred.
http://www.a2zmenu.com/Blogs/Silverlight/Calling-Silverlight-Method-from-JavaScript.aspx
accessing a form that is in an iframe