Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/VB/GridDemo.Wpf/Modules/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/VB/GridDemo.Wpf/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
Imports System.Data
Imports DevExpress.Xpf.Editors


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.xaml"
			End Get
		End Property
		Private ReadOnly Property Categories() As DataView
			Get
				Return CType(NWind.Categories, DataView)
			End Get
		End Property
		Private ReadOnly Property Products() As DataView
			Get
				Return CType(lookUpEdit.DataContext, DataView)
			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}
			Products.BeginInit()
			Dim row As DataRowView = Products.AddNew()
			row("ProductName") = e.DisplayText

			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, .ContainerFocusable = False, .ShowModal = True})

			e.PostponedValidation = True
			e.Handled = True
		End Sub

		Private Sub CloseAddNewRecordHandler(ByVal close? As Boolean)
			Dim row As DataRowView = CType(control.DataContext, DataRowView)
			If Not close.HasValue OrElse (Not CBool(close)) Then
				row.CancelEdit()
			End If
			Products.EndInit()
			control = Nothing
		End Sub
		Protected Overrides Function GetModuleDataContext() As Object
			Return lookUpEdit
		End Function
   End Class
End Namespace