WPF XAML Field Update
WinWrap® Basic is an embedded language control available for .NET/COM 32/64 bit Windows applications. The WinWrap® Basic Component is compatible with VBA, Sax Basic, VB.NET and Visual Basic 6.0 style scripts.
Display custom WPF XAML UI Dialogs from WinWrap® Basic scripts. Incorporate WPF controls. Show custom user interfaces.
Use Custom WPF XAML UI Forms with your WinWrap® Basic Application
- Utilize any Windows Presentation Foundation (WPF) UI Control
- Works with .NET, WPF, and COM applications
- Dynamically display custom WPF UI from XAML description code
- Implement custom user interfaces for specific clients
- Enable power users to implement their own custom interfaces
- Access host application specific extensions
- Requires WinWrap® Basic with WWB-NET scripting option
WinWrap® Basic WPF XAML Field Update Example
- The XAML definition specifies the "Field Update" dialog UI controls and layout.
-
- Use the StackPanel to place the XAML controls on the HTML page
- Define top menu and menuitem mnuExit
- Define textbox firstNameTextBox
- Define textbox lastNameTextBox
- Define textblock fullNameTextBox
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WPF XAML Dialog" Height="350" Width="525">
<StackPanel>
<TextBox
x:Name="firstNameTextBox"
Width="200"
Margin="0,4"
/>
<TextBox
x:Name="lastNameTextBox"
Width="200"
Margin="0,4"
/>
<TextBlock
x:Name="fullNameTextBlock"
Background="LightBlue"
Margin="0,4"
/>
</StackPanel>
</Window>
- "Sub Main" calls the Show method in the NameDialog Class script to display the XAML dialog
'#Language "WWB.NET"
'#Uses "NameDialog.cls"
Sub Main
Dim dlg As New NameDialog
dlg.Show
End Sub
- Create the dialog object and then call its Show method.
-
- Define the dialog window and .NET framework controls
- Read and instantiate the WPF window
- Show the XAML Dialog
- Bind the .NET framework controls to the instantiated XAML dialog elements
- Sink the "txtFirstName_TextChanged" events
- Sink the "txtLastName_TextChanged" events
'#Language "WWB.NET"
Imports System
' Define the dialog window and .NET framework controls
Private WithEvents wndMain As Windows.Window
Private WithEvents txtFirstName As Windows.Controls.TextBox
Private WithEvents txtLastName As Windows.Controls.TextBox
Private WithEvents txtFullName As Windows.Controls.TextBlock
Private Sub Class_Initialize()
Using reader As New Xml.XmlTextReader(MacroDir & "NameDialog.xaml")
wndMain = Windows.Markup.XamlReader.Load(reader)
End Using
' Bind the .NET framework controls to the instantiated XAML dialog elements
txtFirstName = wndMain.FindName("firstNameTextBox")
txtLastName = wndMain.FindName("lastNameTextBox")
txtFullName = wndMain.FindName("fullNameTextBlock")
txtFirstName.Text = "Joshua"
txtLastName.Text = "Lincoln"
End Sub
Private Sub Class_Terminate()
If Not wndMain Is Nothing Then
wndMain.Close
End If
End Sub
' Show the XAML Dialog (modeless - can be debugged in WinWrap Basic)
Public Sub Show()
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(wndMain)
wndMain.Show
While wndMain.IsVisible
Wait .1
End While
End Sub
' Show the XAML Dialog (modal - can't be debugged in WinWrap Basic)
Public Sub ShowDialog()
wndMain.ShowDialog
End Sub
Private Sub txtFirstName_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles txtFirstName.TextChanged
txtFullName.Text = String.Format("{0} {1}", txtFirstName.Text, txtLastName.Text)
End Sub
Private Sub txtLastName_TextChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles txtLastName.TextChanged
txtFullName.Text = String.Format("{0} {1}", txtFirstName.Text, txtLastName.Text)
End Sub
- You can download XamlDialog.zip clicking the following link:
WinWrap® Basic WPF XAML Field Update example.
Then open the Sample.wwp project with WinWrap® Director. WinWrap® Director is part of the WinWrap® Basic Scripting evaluation product.
Copyright Polar Engineering, Inc.