Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/Silverlight/VB/GridDemo/Modules/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/Silverlight/VB/GridDemo/Modules/LookUpEdit.xaml.vb

Imports Microsoft.VisualBasic
Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports DevExpress.Xpf.DemoBase
Imports System.Collections
Imports DevExpress.Xpf.Core
Imports DevExpress.Utils


Namespace CommonDemo
   <CodeFile("ModuleResources/LookUpEditTemplates(.SL).xaml")> _
   Partial Public Class LookUpEdit
	   Inherits CommonDemoModule
		Private privateNWind As NWindDataLoader
		Private Property NWind() As NWindDataLoader
			Get
				Return privateNWind
			End Get
			Set(ByVal value As NWindDataLoader)
				privateNWind = value
			End Set
		End Property
		Private ReadOnly Property GenericXamlName() As String
			Get
				Return "Generic.SL.xaml"
			End Get
		End Property
		Private ReadOnly Property Categories() As IList
			Get
				Return CType(NWind.Categories, IList)
			End Get
		End Property
		Private ReadOnly Property Products() As IList
			Get
				Return CType(lookUpEdit.DataContext, IList)
			End Get
		End Property
		Private ReadOnly Property NewItemRowID() As Integer
			Get
				Return Products.Count + 1
			End Get
		End Property
		Public Sub New()
			Resources.MergedDictionaries.Add(New ResourceDictionary() With {.Source = New Uri(String.Format("/{0};component/Themes/{1}", AssemblyHelper.GetPartialName(GetType(LookUpEdit).Assembly), GenericXamlName), UriKind.Relative)})
			InitializeComponent()
			NWind = TryCast(Resources("NWindDataLoader"), NWindDataLoader)
		End Sub
		Private control As Control
		Private Sub lookUpEdit_ProcessNewValue(ByVal sender As DependencyObject, ByVal e As DevExpress.Xpf.Editors.ProcessNewValueEventArgs)
			If (Not CBool(chProcessNewValue.IsChecked)) Then
				Return
			End If

			control = New ContentControl With {.Template = CType(Resources("addNewRecordTemplate"), ControlTemplate), .Tag = e}
			Dim row As New DevExpress.Xpf.DemoBase.NWind.Products()
			row.ProductName = e.DisplayText
			row.ProductID = NewItemRowID

			control.DataContext = row
			Dim owner As FrameworkElement = TryCast(sender, FrameworkElement)
			Dim closeHandler As DialogClosedDelegate = AddressOf CloseAddNewRecordHandler

			FloatingContainer.ShowDialogContent(control, owner, Size.Empty, New FloatingContainerParameters() With {.Title = "Add New Record", .AllowSizing = False, .ClosedDelegate = closeHandler})
			e.PostponedValidation = True
			e.Handled = True
		End Sub

		Private Sub CloseAddNewRecordHandler(ByVal close? As Boolean)
			If close.HasValue AndAlso CBool(close) Then
				Products.Add(control.DataContext)
			End If
			control = Nothing
		End Sub
		Protected Overrides Function GetModuleDataContext() As Object
			Return lookUpEdit
		End Function
   End Class
End Namespace