using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;

namespace SilverlightApplication1
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			// Required to initialize variables
			InitializeComponent();
		}

        private void RadButton_Click(object sender, RoutedEventArgs e)
        {
            GridViewDataColumn col1 = new GridViewDataColumn();
            col1.Header = "Dynamic Image Column";
            col1.CellTemplate = (DataTemplate)this.LayoutRoot.Resources["dt"];
            this.radGridView1.Columns.Add(col1);
            GridViewDataColumn col2 = new GridViewDataColumn();
            col2.Header = "Another Dynamic Image Column";
            var template = (DataTemplate)XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
                                                    <StackPanel Orientation=""Horizontal"">
                                                    <Image Stretch=""None"" Source=""{Binding Property1}"" Margin=""0,0,5,0""/>
                                                    <TextBlock Text=""{Binding Property2}"" VerticalAlignment=""Center""/></StackPanel></DataTemplate>");
            col2.CellTemplate = template;
            this.radGridView1.Columns.Add(col2);
        }
	}
}