Imports System.Net
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Shapes
Imports C1.Silverlight.FlexGrid

Namespace ExcelStyleMerge
	Partial Public Class MainPage
		Inherits UserControl
		Private _xlMergeManager As ExcelStyleMergeManager

		Public Sub New()
			InitializeComponent()
			_xlMergeManager = New ExcelStyleMergeManager(_flex)
			_flex.MergeManager = _xlMergeManager
			_flex.AllowMerging = AllowMerging.Cells

			For r As Integer = 0 To 49
				_flex.Rows.Add(New Row())
			Next r
			For c As Integer = 0 To 9
				_flex.Columns.Add(New Column())
			Next c
			For r As Integer = 0 To _flex.Rows.Count - 1
				For c As Integer = 0 To _flex.Columns.Count - 1
					_flex(r, c) = String.Format("r{0}, c{1}", r, c)
				Next c
			Next r
		End Sub

		Private Sub _btnMerge_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
			_xlMergeManager.AddMergedRange(_flex.Selection)
		End Sub
		Private Sub _btnSplit_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
			_xlMergeManager.RemoveMergedRange(_flex.Selection)
		End Sub
	End Class
End Namespace
