logo WinWrap®

Display Custom WPF XAML User Interface Windows from WinWrap® Basic Scripts

WinWrap® Basic is an embedded macro language control available for WPF/.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 Windows from WinWrap® Basic scripts. Incorporate any WPF control. Show custom user interfaces for specific clients.

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

Custom WPF Form

Developers and end-users can display custom WPF interfaces from WinWrap® Basic Version 10 scripts. Click here for the web version if you are reading this in an email.

  • Describe WPF forms as a XAML description files
  • Dynamically display the WPF forms from WinWrap® Basic scripts

Dynamically Display Visually Compelling User Forms from WinWrap® Basic Scripts

A XAML description file describes a visually pleasing button against a background image.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Main Window" Height="350" Width="525"> <Window.Background> <ImageBrush ImageSource="img8.jpg"></ImageBrush> </Window.Background> <Window.Resources> ... </Window.Resources> <Grid> <Button Content="OK" Height="90" HorizontalAlignment="Left" Margin="142,101,0,0" Name="btnOK" VerticalAlignment="Top" Width="206" Style="{StaticResource btnGlass}" /> </Grid> </Window>

The XAML description file is loaded dynamically by a WinWrap® Basic Version 10 script to display an aesthetically pleasing WPF UI form and button.

WPF Form Screen

The WinWrap® Basic WWB-NET script code to display this WPF UI is simple and straightforward.

'#Language "WWB.NET" Imports System Dim WithEvents wndMain As Windows.Window Dim WithEvents btnOK As Windows.Controls.Button Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnOK.Click Debug.Print("btnOK clicked at " & Now()) End Sub Sub Main Using reader As New Xml.XmlTextReader(MacroDir & "\wpf-ui.xaml") wndMain = Windows.Markup.XamlReader.Load(reader) End Using btnOK = wndMain.FindName("btnOK") btnOK.ToolTip = "This is a ToolTip!" System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(wndMain) wndMain.Show() While wndMain.IsVisible Wait .1 End While Stop End Sub

You can download and run this WPF XAML description file and WinWrap® Basic script by clicking this link WinWrap® Basic WPF Forms Demo.

  1. Unzip the wpf-ui.zip file
  2. Load wpf-ui.wwd into WinWrap® Director
  3. Run the wpf-ui.wwd script
  4. Click the WPF UI OK button
  5. The button visually depresses
  6. An event is sent to the WinWrap® Basic script event handler

It's Simple to Write a WinWrap® Basic Script to Display a WPF Form

First, code the script to accept WPF button events.

Tell the script to accept WPF button events

WinWrap® makes it easy to use the WPF UI button click event. Just select the btnOK Object in WinWrap® object list.

Select btnOK Object

Then select the btnOK Click Event in the WinWrap® proc list.

Select btnOK Click Event

Now WinWrap® automatically writes the event prototype into your script code!

btnOK_Click event code

Place the desired event handler code in the btnOK_Click event handler subroutine and you have wired your custom WPF UI to your WinWrap® Basic script. This was easy!

Two Tools for Designing WPF XAML Description Files

"Kaxaml is a lightweight XAML editor that gives you a "split view" so you can see both your XAML and your rendered content." http://kaxaml.com/

"XamlPad is a nice tool for viewing how the Xaml looks like and is used quite a lot for repro'ing bugs and debugging to some extent." http://blogs.msdn.com

Conclusions

It's easy to dynamically display custom WPF UI forms from WinWrap® Basic Version 10 scripts.

Developers, and end-users, can easily display visually appealing and powerful WPF UI Forms from their WinWrap® Basic application scripts.

Copyright Polar Engineering, Inc.