Application = WinformsDataBindingApp IDEVersion = 1.11 GalleryName = GalleryPage = GalleryDefaultName = Target = 1 Platform = AnyCPU Language = XSharp Runtime = CLR4 Dialect = Core Folder = %ProjectPath%\Applications\WinformsDataBindingApp\ PrgSubFolder = \Prg ResourcesSubFolder = \Resources Description = A sample for a WinForms DataBinding NameSpace = Assembly = WinformsDataBindingApp Extension = ApplicationIcon = OutputFolder = Frameworks = 1 GUID = B6293546-815A-405C-A080-4F4269DF40FC IncludeInProjectBuild = 1 IncludeInProjectSearch = 1 IncludeInProjectExport = 1 IncludePath = SignAssembly = 0 KeyFile = [ExportOptions] ExportResources = 1 ExportImages = 1 [WinformsDataBindingApp FileGroups] [WinformsDataBindingApp Files] File = %AppPath%\Prg\Start.prg FileGUID = 03C87259-F6FB-4B3E-833C-C74EFD5F6F08 FileType = Code File = %AppPath%\Prg\BaseView.prg FileGUID = 0151CD3D-4775-476F-B83B-088650571E60 FileType = Code File = %AppPath%\Prg\BindableBase.prg FileGUID = F7CC8ADC-8250-41A5-8ABE-5535A50A390D FileType = Code File = %AppPath%\Prg\SampleViewModel.prg FileGUID = 244E079D-9B6A-41A0-804F-9C9410900E56 FileType = Code File = %AppPath%\Prg\SampleView.prg FileGUID = 444D020F-E610-463A-BD9B-2C2F7844820E FileType = Code [WinformsDataBindingApp References] ReferenceGAC = CLR4,System,1,0,4.0.0.0 ReferenceGAC = CLR4,System.ComponentModel,1,0,4.0.0.0 ReferenceGAC = CLR4,System.Drawing,1,0,4.0.0.0 ReferenceGAC = CLR4,System.Windows.Forms,1,0,4.0.0.0 [WinformsDataBindingApp Resources] [WinformsDataBindingApp Native Resources] [WinformsDataBindingApp License files] [WinformsDataBindingApp General Options] Switches= ZeroArrays=0 CaseSensitive=0 ImplicitNamespace=0 VO1=0 VO2=0 VO3=0 VO4=0 VO5=0 VO6=0 VO7=0 VO8=0 VO9=0 VO10=0 VO11=0 VO12=0 VO13=0 VO14=0 VO16=0 LateBound=0 Unsafe=0 IgnoreStdDefs=0 Ovf=0 FOvf=0 ResponseOnly=0 [WinformsDataBindingApp Configurations] AppConfig = Debug,11111111-1111-1111-1111-111111111111 Switches= SwitchesCF= CommandLine= CommandLineCF= Debug=1 DebugInit=1 DefineDebug=1 DefineTrace=0 SyntaxOnly=0 WarningsErrors=0 ForceConsole=0 ForceX86=0 AppConfig = Release,22222222-2222-2222-2222-222222222222 Switches= SwitchesCF= CommandLine= CommandLineCF= Debug=0 DebugInit=0 DefineDebug=0 DefineTrace=0 SyntaxOnly=0 WarningsErrors=0 ForceConsole=0 ForceX86=0 ENDApplication = WinformsDataBindingApp [FileContents] %#IDE#%File=TEXT,03C87259-F6FB-4B3E-833C-C74EFD5F6F08 #using System.Windows.Forms #using System.Drawing [STAThreadAttribute]; function Start( asCmdLine as string[] ) as int local nExitCode as int local oSampleView as SampleView Application.EnableVisualStyles() Application.DoEvents() oSampleView := SampleView{} oSampleView:Use( SampleViewModel{} ) Application.Run( oSampleView ) return nExitCode %#IDE#%File=TEXT,0151CD3D-4775-476F-B83B-088650571E60 // Application : WinformsDataBindingApp // BaseView.prg , Created : 13.01.2018 17:59 // User : Wolfgang using System.Windows.Forms using System.ComponentModel class BaseView inherit Form constructor() return method Use( oViewModel as INotifyPropertyChanged ) as void local oControls as System.Windows.Forms.Control.ControlCollection local oTextBox as TextBox oControls := self:Controls foreach oControl as Control in oControls do case case oControl is TextBox oTextBox := ( TextBox ) oControl oTextBox:DataBindings:Add( "Text", oViewModel, oTextBox:Name ) endcase next return end class %#IDE#%File=TEXT,F7CC8ADC-8250-41A5-8ABE-5535A50A390D // Application : WinformsDataBindingApp // BindableBase.prg , Created : 13.01.2018 18:00 // User : Wolfgang using System.ComponentModel using System.Runtime.CompilerServices using System.Collections.Generic using System.Diagnostics public abstract class BindableBase implements INotifyPropertyChanged /// /// Baseclass for implementing the INotifyPropertyChanged interface. Here'a sample for using it: /// public string FirstName /// { /// get { return Get(); } /// set { Set(value); } /// } /// protect _properties := Dictionary{} as Dictionary public event PropertyChanged as PropertyChangedEventHandler protected method _Get( [CallerMemberName] name := null as string ) as T /// /// Gets the value of a property /// /// /// /// local value := null as object Debug.Assert( name != null, "name != null" ) if _properties.TryGetValue( name, out value ) if value == null return Default(T) else return (T) value endif // return value == null ? Default(T) : (T)value endif return Default(T) protected method _Set( value as T, [CallerMemberName] name := null as string ) as void /// /// Sets the value of a property /// /// /// /// /// Use this overload when implicitly naming the property // Debug.Print( "passed Name is " + name + ", passed value is " + value.ToString() ) Debug.Assert(name != null, "name != null") if ( Equals( value, _Get(name) ) ) return endif _properties[name] := value OnPropertyChanged( name ) return protected virtual method OnPropertyChanged([CallerMemberName] propertyName := null as string ) as void local handler as PropertyChangedEventHandler handler := self:PropertyChanged if handler != null handler( self, PropertyChangedEventArgs{ propertyName } ) endif return end class %#IDE#%File=TEXT,244E079D-9B6A-41A0-804F-9C9410900E56 // Application : WinformsDataBindingApp // SampleViewModel.prg , Created : 13.01.2018 18:12 // User : Wolfgang using System.ComponentModel class SampleViewModel inherit Bindablebase constructor() // Test-Daten self:SampleId := "12345" self:SampleName := "Name of the sample" self:SampleDescription := "Description of the sample" return property SampleId as string get self:_Get() set self:_Set( value ) property SampleName as string get self:_Get() set self:_Set( value ) property SampleDescription as string get self:_Get() set self:_Set( value ) end class %#IDE#%File=TEXT,444D020F-E610-463A-BD9B-2C2F7844820E // Application : WinformsDataBindingApp // SampleView.prg , Created : 13.01.2018 18:15 // User : Wolfgang class SampleView inherit BaseView protect oCloseButton as System.Windows.Forms.Button protect oSC_SampleDescription as System.Windows.Forms.Label protect oSampleDescription as System.Windows.Forms.TextBox protect oSC_SampleName as System.Windows.Forms.Label protect oSampleName as System.Windows.Forms.TextBox protect oSampleId as System.Windows.Forms.TextBox protect oSC_SampleId as System.Windows.Forms.Label // User code starts here (DO NOT remove this line) ##USER## constructor() super() self:InitializeForm() return method InitializeForm() as void // IDE generated code (please DO NOT modify) self:oCloseButton := System.Windows.Forms.Button{} self:oSC_SampleDescription := System.Windows.Forms.Label{} self:oSampleDescription := System.Windows.Forms.TextBox{} self:oSC_SampleName := System.Windows.Forms.Label{} self:oSampleName := System.Windows.Forms.TextBox{} self:oSampleId := System.Windows.Forms.TextBox{} self:oSC_SampleId := System.Windows.Forms.Label{} self:SuspendLayout() self:ClientSize := System.Drawing.Size{448 , 136} self:Location := System.Drawing.Point{100 , 100} self:Name := "SampleView" self:Text := "SampleView" self:oCloseButton:Location := System.Drawing.Point{328 , 104} self:oCloseButton:Name := "CloseButton" self:oCloseButton:Size := System.Drawing.Size{115 , 23} self:oCloseButton:TabIndex := 6 self:oCloseButton:Text := "Close" self:Controls:Add(self:oCloseButton) self:oSC_SampleDescription:Location := System.Drawing.Point{8 , 72} self:oSC_SampleDescription:Name := "SC_SampleDescription" self:oSC_SampleDescription:Size := System.Drawing.Size{120 , 23} self:oSC_SampleDescription:TabIndex := 4 self:oSC_SampleDescription:Text := "Sample Description" self:Controls:Add(self:oSC_SampleDescription) self:oSampleDescription:Location := System.Drawing.Point{128 , 72} self:oSampleDescription:Name := "SampleDescription" self:oSampleDescription:Size := System.Drawing.Size{312 , 20} self:oSampleDescription:TabIndex := 5 self:Controls:Add(self:oSampleDescription) self:oSC_SampleName:Location := System.Drawing.Point{8 , 40} self:oSC_SampleName:Name := "SC_SampleName" self:oSC_SampleName:Size := System.Drawing.Size{120 , 23} self:oSC_SampleName:TabIndex := 2 self:oSC_SampleName:Text := "Sample Name" self:Controls:Add(self:oSC_SampleName) self:oSampleName:Location := System.Drawing.Point{128 , 40} self:oSampleName:Name := "SampleName" self:oSampleName:Size := System.Drawing.Size{312 , 20} self:oSampleName:TabIndex := 3 self:Controls:Add(self:oSampleName) self:oSampleId:Location := System.Drawing.Point{128 , 8} self:oSampleId:Name := "SampleId" self:oSampleId:Size := System.Drawing.Size{100 , 20} self:oSampleId:TabIndex := 1 self:Controls:Add(self:oSampleId) self:oSC_SampleId:Location := System.Drawing.Point{8 , 8} self:oSC_SampleId:Name := "SC_SampleId" self:oSC_SampleId:Size := System.Drawing.Size{120 , 23} self:oSC_SampleId:TabIndex := 0 self:oSC_SampleId:Text := "Sample Id" self:Controls:Add(self:oSC_SampleId) self:ResumeLayout() return end class %#IDE#%FileDesigner=TEXT,444D020F-E610-463A-BD9B-2C2F7844820E DESIGNERSTART = Form,Form,SampleView GUID=2376628E-06AD-44FE-9E8E-3648EDFA6682 Name=SampleView Text=SampleView Location=100 , 100 ClientSize=448 , 136 Inherit=BaseView ControlPrefix=o CallPreResumeLayout=No CallSuperInitialize=No UseGrid=Yes GridX=8 GridY=8 SUBCONTROLSSTART CONTROL=System.Windows.Forms.Button GUID=796B093F-4446-44FF-BE78-88A0F3BC498E Name=CloseButton Text=Close Location=328 , 104 Size=115 , 23 TabIndex=6 CONTROL=System.Windows.Forms.Label GUID=2E3BA75D-F4C0-4577-B38F-073D36216371 Name=SC_SampleDescription Text=Sample Description Location=8 , 72 Size=120 , 23 TabIndex=4 CONTROL=System.Windows.Forms.TextBox GUID=0C0C05B4-46D2-4683-9647-047838304C01 Name=SampleDescription Location=128 , 72 Size=312 , 20 TabIndex=5 CONTROL=System.Windows.Forms.Label GUID=111084FB-A01D-4BD4-B572-5FE27A21365C Name=SC_SampleName Text=Sample Name Location=8 , 40 Size=120 , 23 TabIndex=2 CONTROL=System.Windows.Forms.TextBox GUID=B62DCDE0-E8BA-4EDA-93AF-86F5E9344B9E Name=SampleName Location=128 , 40 Size=312 , 20 TabIndex=3 CONTROL=System.Windows.Forms.TextBox GUID=4D861430-1E06-452E-BE46-C2B2629F2FA3 Name=SampleId Location=128 , 8 Size=100 , 20 TabIndex=1 CONTROL=System.Windows.Forms.Label GUID=9D01EFA6-294C-4BCF-83E1-C0D18043CB34 Name=SC_SampleId Text=Sample Id Location=8 , 8 Size=120 , 23 TabIndex=0 SUBCONTROLSEND DESIGNEREND = SampleView