Universal WPF Addin for NAV v1.3

Hello everybody

After some time, there is new version of my UniWPF addin. Now with possibilities to dynamically add and remove elements, read their properties and bind their properties together with some additional calulations (using Xaml LambdaConverter).

Usage:

This addin is now ready to be used e.g. for creating touch screens for POS and other systems dynamically, to display dynamically created buttons, drawings, pictures, media (you can easily play some video inside…). All the properties of WPF are used, thus the content is automatically resized if all is set correctly inside the XAML (data binding the controls between each other). Example is the calculator with some demo functions using all aspects of the addin.

 

What’s new in v1.3

  • In the Element you can now use the Parent attribute to select parent element. All elements defined by the XAML will be added as children of this parent. Parent must be descendant of Panel class.

  <Element Parent=”ParentName”>
    //there is XAML describing the controls which should be added into the addin, the XAML must include correct name spaces
  </Element>

  • There is new element with name DelElement which allows you to remove selected element from selected parent.

    <DelElement Parent="parentname" ObjectName="objname"/>

  • When binding attributes of elements together, you can now use the LambdaConverter to manipulate the value. Example is the ellipse in the added button, which is binded to the size of the button. Without the converter, the size of the ellipsis would be each time same as the size of the button, thus leading to not nice result. But when we define the converter like:

<Grid Name="mygrid" Grid.Row="1" Grid.Column="2" Margin="2,20,2,2"
  xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
  xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
  xmlns:XamlConverter="clr-namespace:XamlConverter;assembly=XamlConverter"
  xmlns:System="clr-namespace:System;assembly=mscorlib">
  <Grid.RowDefinitions>
    <RowDefinition Height="50*" />
    <RowDefinition Height="50*" />
  </Grid.RowDefinitions>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="61*" />
    <ColumnDefinition Width="70*" />
    <ColumnDefinition Width="69*" />
  </Grid.ColumnDefinitions>
  <Grid.Resources>
    <XamlConverter:LambdaConverter x:Key="smaller">value-10</XamlConverter:LambdaConverter>
  </Grid.Resources>

we can now bind the size of the ellipsis with the size of the button with calculation like this:


<Ellipse Width="{Binding ElementName=mybutton4, Path=ActualWidth, Converter={StaticResource smaller}}"
  Height="{Binding ElementName=mybutton4, Path=ActualHeight, Converter={StaticResource smaller}}" Stroke="Black"\>

This binding takes the value of ActualWidth attribute of the mybutton4 element and pass it into the converter with name “smaller” which will subtract 10 from the value and return the result. You can define own converter for what you need. Notice, that the namespace must be defined in the XAML to tell parser where to look for the class LambdaConverter used to define the converter. This class is defined in assembly XamlConverter, which is attached to my addin.

If you use correct namespace definition, you can define any class in the XAML. Grid is just a class from the default namespace. Button is just another class from the namespace. If you create own assembly with own controls, you can use them in a same way. Just define the namespace and add appropriate elements into the XAML.

Demo

I am still using the horrible calc demo, but I am planning to create some more complex demo in future to show the possibilities of the addin in better way. If you want to help me, I am open to collaboration.

You can download the files there.

2 thoughts on “Universal WPF Addin for NAV v1.3”

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>