Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts

Thursday, January 19, 2012

Ironpython hosting in SilverLight

Here is one of the simplest sample i could make to illustrate.
The only issue i encoutered was adding a reference to 'Microsoft.CSharp'

using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Scripting.Silverlight;


///
/// script.py => def Adder (x, y) : return x + y
///


namespace DLRSilverlight
{
    public partial class MainPage : UserControl
    {
        dynamic runtime = DynamicEngine.CreateRuntime().UseFile("script.py");
               
        public MainPage()
        {
            InitializeComponent();                  
        }
       
        private void button1_Click(object sender, RoutedEventArgs e)
        {            
            dynamic result = runtime.Adder(Convert.ToDouble(this.N1.Text), Convert.ToDouble(this.N2.Text));
            MessageBox.Show(String.Format("{0}", result));
        }        
    }
}

Wednesday, January 4, 2012

Data and Command Bindings for Silverlight MVVM Applications

Quote from site :

(...)This article summarizes two utility classes used for data and command bindings in Silverlight MVVM applications and demonstrates how to use the two classes with a running example. (...)
http://www.codeproject.com/KB/silverlight/MVVMUtility.aspx

Thursday, December 22, 2011

Playing with Ironpython and Silverlight

Ironpython plays nicely with Silverlight, especially when using
Gestalt.

Here is how I manage to pass arguments to a 'click event' handler,
assuming you have a button whith an id equal to 'Button1'

<script type="text/python">
        import System
        from System import EventHandler
        class Person(object):
            def __init__(self, name):
                self.name = name
                self.greeted = False        
        def GreetHandler(p):
            def SayHello(s,e):
                if not p.greeted:
                    window.Alert("Hello " + p.name)                    
                else:                    
                    window.Alert("Happy to see you again  " + p.name)
                p.greeted = not p.greeted        
            return SayHello
        p = Person("PAUL")
        document.Button1.AttachEvent('onclick',EventHandler(GreetHandler(p)))
</script>

Friday, April 29, 2011

Use OData data with WCF Data Services and Silverlight 4

(...)The purpose is to build a Silverlight master-detail application composed of a ComboBox control to choose a customer and a DataGrid Control to see all the Customer orders. We will use Customers and Orders tables from Northwind OData feed which is at this address : http://services.odata.org/Northwind/Northwind.svc/(...)

http://msmvps.com/blogs/audrey/archive/2010/06/10/odata-use-odata-data-with-wcf-data-services-and-silverlight-4.aspx

By Audrey Petit