Size: 6052
Comment:
|
Size: 6076
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 54: | Line 54: |
`FixSimpleXaml` is a function used to execute the Xaml and return the root element as a .Net object. All the other elements that are named in the Xaml will be attached by their named to the root object. For example the element '''!TextBox''' that is named '''textBox1''' and the element '''Button''' that is named '''button1''' are attached automatically to the root element: | `FixSimpleXaml` is a function used to execute the Xaml and return the root element as a .Net object. All the other elements that are named in the Xaml will be attached by their names to the root object. For example the element '''!TextBox''' that is named '''textBox1''' (line 15) and the element '''Button''' that is named '''button1''' (line 22) are attached automatically to the root element: |
Line 62: | Line 62: |
That way you don't need to define a separate variable for each named element. If you install the User Command [[sfPropGrid||target="_blank"]] you can see all the properties and methods of the named objects by doing: | That way you don't need to define a separate variable for each named element. If you install the User Command [[sfPropGrid||target="_blank"]] you can see all the properties, methods and events of the named objects by doing: |
Line 68: | Line 68: |
`FixSimpleXaml` is a quick function to used on simple Xaml that do not have events and are properly formed. For cases where there is events that need to be fixed and error handling is necessary the function `FixXaml` is available. It is useful when testing Xaml directly taken from the Web or from Visual Studio.<<BR>> | `FixSimpleXaml` is a quick function to use on simple Xaml that do not have events and are properly formed. For cases where there is events that need to be fixed and error handling is necessary the function `FixXaml` is available. It is useful when testing Xaml taken directly from the Web or from Visual Studio.<<BR>> |
Line 119: | Line 119: |
The User Command [[wpfXamlEditor||target="_blank"]] is also useful to edit the Xaml saved in the workspace. | The User Command [[wpfXamlEditor||target="_blank"]] is designed to edit the Xaml saved in the workspace. |
wpfXamlDemo
UNDER CONSTRUCTION
wpfXamlDemo is a Dyalog APL namespace that demonstrate the use of WPF Xaml with some utility functions.
WHAT IS XAML ?
XAML stands for Extensible Application Markup Language (and pronounced "Zammel"). It's a simple language based on XML to create and initialize .NET objects with hierarchical relations. All you can do in XAML can also be done in code. XAML is just another way to create and initialize objects. You can use WPF without using XAML. It's up to you if you want to declare it in XAML or write it in code. See UsingWPF_from_APLX for a more complete introduction. Here is an example of Xaml found in the attached namespace called sample1: Show sample1
FixSimpleXaml
If you install the attached workspace and execute the following 2 lines:
win ← FixSimpleXaml sample1 win.Show
The following Window is displayed:
FixSimpleXaml is a function used to execute the Xaml and return the root element as a .Net object. All the other elements that are named in the Xaml will be attached by their names to the root object. For example the element TextBox that is named textBox1 (line 15) and the element Button that is named button1 (line 22) are attached automatically to the root element:
win.textBox1.Text Textbox win.button1 System.Windows.Controls.Button: Click Me !
That way you don't need to define a separate variable for each named element. If you install the User Command sfPropGrid you can see all the properties, methods and events of the named objects by doing:
]noe win ⍝ noe = .Net Object Explorer
FixXaml
FixSimpleXaml is a quick function to use on simple Xaml that do not have events and are properly formed. For cases where there is events that need to be fixed and error handling is necessary the function FixXaml is available. It is useful when testing Xaml taken directly from the Web or from Visual Studio.
For example, with the Xaml code in sample2 that has an event on the button (Click="__Button_Click") at line 24, if you do the following:
Show sample2
win ← FixXaml sample2 win.Show
and then if you click on the button, the value of the TextBox will change. The value of the TextBox can be retrieved by doing:
win.textBox1.Text I Was Clicked !
The function __Button_Click is handling the event. The author has taken the convention of naming the callback functions with a double underscore prefix. The goal is to be able to take the Xaml directly from Visual Studio to APL. The single underscore '_' is a valid first character in Visual Studio and APL but is in conflict with the menu object that will accept an underscore as first character to signify a keyboard shortcut. The line 5 of sample2 (x:Class="WpfApplication3.MainWindow") that is necessary to Visual Studio is also removed by FixXaml. See the comments of the individual functions for more information.
The User Command wpfXamlEditor is designed to edit the Xaml saved in the workspace.
How to install wpfXamlDemo in your workspace
Download wpfXamlDemo.v1.0.txt
- Do a Select all (Ctrl+A) and a copy (Ctrl+C).
In your workspace execute )ed ⍟ wpfXamlDemo
- Paste (Ctrl+V) the text into the Dyalog editor
- Press Escape and ')save' your workspace
Version Information
Original author: |
Pierre Gilbert |
Responsible: |
|
Email: |
<apgil AT SPAMFREE videotron DOT ca> |