Windows 8 Developer Preview (First Look)

On September 18, 2011, in Programming, Technology, by Akash Kava

I installed Windows Developer Preview of upcoming operating system Windows 8, and it has few good and bad things. Just like a new product, it has new dashboard and cool way to navigate between apps using touch gesture, these things sure excites me up but also looking at the internals, there are more challenges for everyone to catch up with Window 8.

New Task Manager

Nice of all, I like the new improved Task Manager, which lets me look into complete Process Tree as well as I can see user wise Process Tree.

WindowsTaskManager

It also displays Process Tree grouped by Users.

UserProcesses

And best of all, it lets me control my startup items from here, I can disable items I don’t want to auto start.

StartupItems

New File Copy Dialog

Another improved user interface is, File Copy dialog, instead of old style animation, it now displays a graph of progress with real cool line graph that’s very live.

FileCopyDialog

New Search

Search is redesigned completely and you can search for settings by pressing Window + W key. Let’s say I want to change my desktop background, so I pressed Window + W and I typed “wallpaper”, it did give me these options.

Well I just tried all combinations of Window keys and only found following five useful combinations.

  1. Window + W lets you search the settings (usually control panel)
  2. Window + P lets you switch between dual desktop and connect to projector settings
  3. Window + D brings back the desktop
  4. Window + F lets you search the files
  5. Window + Q lets you search Metro App’s Items

To a big disappointment, I did not find anything to search apps, so I have to click on Windows + W and then click on App to actually search applications installed on my machine.

Wallpaper

No Old Apps on Metro Desktop

Metro UI Apps are redesigned using HTML5+JS and Appx with Windows Runtime (XAML + Windows Runtime). So none of your old Win32, .NET apps will execute on Metro UI. They can only execute inside the desktop (old fashion windows). So we have to redesign and rewrite the applications for Metro Desktop completely from scratch.

Metro Desktop Apps are not Silverlight

Although they quite look like silverlight, but looking at the documentation, Microsoft has introduced complete new set of library with “Windows.UI” namespace, which represents complete copy of Silverlight controls (and more) but they are not silverlight. So if you wrote your apps in Silverlight, they wont directly run on Metro UI, but you might be able to port them to Metro UI with some code changes as namespace changes System.Windows.Controls to Windows.UI.Controls. However, it may not be so easy but you will get very unexpected behavior if you try to port it directly.

Three Different UI Technologies to Deal With

Well the only sad part is, now we have total 3 different UI technologies to deal with.

  1. WPF 3.0, 3.5, 4.0 (Original WPF based on XAML). Apps written on WPF are old fashioned, and they will not execute on Metro UI, they will only run in Desktop version.
  2. Silverlight (Web and Phone), Once again, two different forms of same Silverlight for web and phone. However all web that runs Silverlight (and even flash) wont run on Metro UI.
  3. Windows Runtime (XAML,HTML5+JS), this is complete new set of library including various controls from Silverlight and WPF, however it is still not complete with both of them and it also includes more controls of its own. This is purely for Metro UI. HTML5 and JS are once again little different as Microsoft has its own API embedded to make developers feel easy to write code. But this does not mean that your HTML5 code will work absolutely correctly without any changes on Metro UI. In IE 10, it may run, but to make it an appx, you might need to change few things.

As new UI stack is introduced by Microsoft, we will soon release a new version of “UI Atoms” that will allow users to write Windows Runtime Metro UI apps with UI Atoms Controls.

Share
Tagged with:  

UI Atoms 1.7.5 Released

On April 3, 2011, in C#, Programming, RIA, Technology, by Akash Kava

We are happy to announce new release of UI Atoms 1.7.5 with following new features.

  1. New AtomDataForm Control
  2. Tabs in AtomForm and AtomDataForm
  3. Lambda Binding Extensions

Introducing new Control AtomDataForm

AtomForm did support UI Validations, however Microsoft RIA Services Client has some inbuilt validation and support for IEditableObject. So we created a new AtomDataForm that supports RIA Services validation and IEditableObject support.

  1. AtomDataForm supports object with IEditableObject interface and fires event for BeginEdit, CancelEdit and EndEdit
  2. AtomDataForm displays items in read only mode unless Edit button is clicked
  3. After edit button is clicked, Save and Cancel button appear for you to persist changes or cancel changes
  4. AtomDataForm contains UI Element (TextBox, ComboBox etc) as children, so you can easily define child ui element in your xaml as shown in sample below
  5. AtomDataForm supports Tabbed layout, for that you can insert your items within AtomDataFormTab as shown in example below
  6. Following sample illustrates Tabs, but you can also create simple user interface without tab as well
  7. You can also use AtomDataFormGroup to group items in to a headered group
  8. Every child element of AtomDataForm can be accessed in code behind file easily because they appear as a variables when you define x:Name property
  9. AtomDataForm supports CanChangeDataContext property, which is false when the form is in edit mode
  10. You can easily reuse any third party control within AtomDataForm, AtomDataFormGroup and AtomDataFormTab
AtomDataForm Sample
  1. <ns:AtomDataForm
  2.     Grid.Column="1"
  3.     DataContext="{Binding SelectedItem,ElementName=dataGrid}" >
  4.             
  5.     <!– 1st Tab–>
  6.     <ns:AtomDataFormTab Header="Default">
  7.                 
  8.         <TextBox
  9.             ns:AtomDataForm.Label="Name:"
  10.             Text="{Binding ProductName, Mode=TwoWay}"/>
  11.                 
  12.         <ns:AtomToggleButtonBar
  13.             ns:AtomDataForm.Label="Type:"
  14.             SelectedItem="{Binding ProductType,Mode=TwoWay}">
  15.             <sys:String>Product</sys:String>
  16.             <sys:String>Service</sys:String>
  17.         </ns:AtomToggleButtonBar>
  18.                 
  19.         <TextBox
  20.             ns:AtomDataForm.Label="Folder:">
  21.             <ns:AtomDataForm.CommandBox>
  22.                 <Button Content="…"/>
  23.             </ns:AtomDataForm.CommandBox>
  24.         </TextBox>
  25.                 
  26.     </ns:AtomDataFormTab>
  27.             
  28.     <!– 2nd Tab–>
  29.     <ns:AtomDataFormTab Header="General">
  30.                 
  31.         <TextBox
  32.             ns:AtomDataForm.Label="Email:"  
  33.             Text="{Binding Email, Mode=TwoWay}"/>
  34.                 
  35.     </ns:AtomDataFormTab>
  36.             
  37.     <!– 3rd Conditional Tab–>
  38.     <!– This tab will be visible only if Product's
  39.     IsTypeService is true–>
  40.     <ns:AtomDataFormTab
  41.         Header="Service"
  42.         IsEnabled="{Binding IsTypeService}">
  43.                 
  44.         <TextBox
  45.             ns:AtomDataForm.Label="Service Details:"/>
  46.                 
  47.     </ns:AtomDataFormTab>
  48.  
  49.     <!– 4th Conditional Tab–>
  50.     <!– This tab will be visible only if Product's
  51.     IsTypeProduct is true–>
  52.     <ns:AtomDataFormTab
  53.         Header="Product"
  54.         IsEnabled="{Binding IsTypeProduct}">
  55.                 
  56.         <TextBox ns:AtomDataForm.Label="Product Details:" >
  57.             <ns:AtomDataForm.CommandBox>
  58.                 <Button Content="Search"/>
  59.             </ns:AtomDataForm.CommandBox>
  60.         </TextBox>
  61.                 
  62.     </ns:AtomDataFormTab>
  63.             
  64. </ns:AtomDataForm>

In above sample you can notice following things,

  1. Header property of AtomDataFormTab is displayed in the title section on the top
  2. AtomDataFormTab contains children and each child can have properties as below
    1. ns:AtomDataForm.Label displays label on left side
    2. ns:AtomDataForm.Description displays description on bottom
    3. ns:AtomDataForm.Title displays title on the top of control
    4. ns:AtomDataForm.CommandBox displays a UI Element on the right corner, usually a search button or expand button
  3. AtomDataFormTab supports IsEnabled binding, you can bind this property to show/hide the tab as shown in the example above
  4. Every child elemen of either AtomDataForm , AtomDataFormTab or AtomDataFormGroup supports Visibility and IsEnabled binding
    1. If Visibility is bound and it results in Collapsed then entire form item is not displayed
    2. IsEnabled binding can enable/disable the editable control

Following is screenshot of Tabbed AtomDataForm in edit mode

AtomDataForm

Introducing Lambda Binder Extensions

Writing binding expressions with conditions and converters can be very complex especially rewriting many and same logic at different classes. Now UI Atoms support, Lambda Binding Extensions which lets you do binding within the code without creating any complex IValueConverter implementation.

Bind Method Extension

Element Property Binding
  1. theForm.Bind(AtomDataForm.HeaderProperty,
  2.     () => string.Format("{0} ({1})",
  3.             productName.Text,
  4.             typeToggleButtonBar.SelectedItem
  5.         ));

This will bind theForm’s Header property to an expression that will combine properties of two different elements. And this will also automatically update when any of bound source or its property will change.

DataContext Property Binding
  1. theForm.Bind(AtomDataForm.HeaderProperty,
  2.     () => string.Format("{0} ({1})",
  3.             theForm.DataContext.Property("ProductName"),
  4.             theForm.DataContext.Property("ProductType")
  5.         ));

Assuming, we may not have property information at design time, but we know that DataContext will be set to an object containing properties, then we can write Property extension method as shown above.

BindVisibility Method Extension

Visibility converters are very frequent so we created a BindVisibility extension method that will let you specify a boolean expression that will be converted to Visibility on the fly.

BindVisibility Extension
  1. productTab.BindVisibility(
  2.     () =>
  3.         typeToggleButtonBar.SelectedIndex == 0);

These extensions can be used anywhere in any third party controls as well.

Download Now

Click here to download your free demo copy of NeuroSpeech UI Atoms 1.7.5

Share
Tagged with:  

Lambda Binder for WPF and Silverlight

On March 20, 2011, in C#, Technology, by Akash Kava

LambdaBinder class helps in creating complex binding expressions without having to create IValueConverter and IMultiValueConverter, it lets you write inline expresions with advanced binding scenarios.

Lets say, you have two TextBox for first and last name and you want a Title to be displayed as addition of both.

So lets say, you can write it as follow,

Adding Two Properties
title.Bind(TextBlock.TextProperty,
    () => firstName.Text + " " + lastName.Text);

Formatting Properties
title.Bind(TextBlock.TextProperty,
    () => string.Format("{0} {1}",
        firstName.Text, lastName.Text));

You can pass on the Linq expression to Bind extension method of LamdaBinder and that will convert and set binding so that anytime if firstName or lastName is modified, the title will be updated automatically.

Assuming I want some hypothetical visibility logic, for example, only if the firstName is entered, lastName should be visible.

Conditional Visibility Binding
lastName.Bind(TextBox.VisibilityProperty,
    () => firstName.Text.Length > 0 ? Visibility.Visible :
        Visibility.Collapsed);

You can also use this to avoid writing IValueConverters and do inline binding in code very easily.

Lambda Binder
public static class LambdaBinder
{

    public static void Bind(
        this DependencyObject dest,
        DependencyProperty destProperty,
        Expression<Func<object>> func)
    {
        MultiBinding b = new MultiBinding();
        b.Converter = new MultiDelegateConverter(func.Compile());
        LambdaBindingBuilder bb = new LambdaBindingBuilder(b);
        bb.Visit(func.Body);
        BindingOperations.SetBinding(dest, destProperty, b);
    }

}

public class LambdaBindingBuilder : ExpressionVisitor
{
    private MultiBinding multiBinding;

    private string lastPath = null;

    public LambdaBindingBuilder(MultiBinding mb)
    {
        this.multiBinding = mb;
    }

    protected override System.Linq.Expressions.Expression VisitMember(MemberExpression node)
    {
        PropertyInfo p = node.Member as PropertyInfo;
        if (p != null) {
            if (string.IsNullOrWhiteSpace(lastPath))
            {
                lastPath = p.Name;
            }
            else {
                lastPath = p.Name + "." + lastPath;
            }
        }
        FieldInfo f = node.Member as FieldInfo;
        if (f != null) {
            Binding b = new Binding(lastPath);
            b.Source = System.Linq.Expressions.Expression.Lambda<Func<object>>(node).Compile()();
            multiBinding.Bindings.Add(b);
            lastPath = null;
        }
        return base.VisitMember(node);
    }

    protected override System.Linq.Expressions.Expression VisitConstant(ConstantExpression node)
    {
        if (!string.IsNullOrWhiteSpace(lastPath)) {
            Binding b = new Binding(lastPath);
            b.Source = node.Value;
            multiBinding.Bindings.Add(b);
            lastPath = null;
        }
        return base.VisitConstant(node);
    }
}

public class MultiDelegateConverter : IMultiValueConverter
{
    private Func<object> func;

    public MultiDelegateConverter(Func<object> func)
    {
        this.func = func;
    }

    public object Convert(object[] values,
        Type targetType,
        object parameter,
        System.Globalization.CultureInfo culture)
    {
        return func();
    }

    public object[] ConvertBack(object value,
        Type[] targetTypes,
        object parameter,
        System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

 

LambdaBinder is part of UI Atoms suite. At NeuroSpeech, we do research on UI and we are coming up with more interesting featues in UI Atoms.

Please Click Here to download latest update of UI Atoms with AtomForm including Tabs in the form.

Share
Tagged with:  

UI Atoms 1.5.8 Released

On January 11, 2011, in Programming, by Akash Kava

We are happy to announce new release of UI Atoms 1.5.8 with following new features.

UI Atoms for WPF 4.0

In this release of UI Atoms, we have a new library of dlls specially designed for WPF 4.0, which now includes support for Visual State Managers and renders everything in WPF 4.0 presentation. You can find Bin.Net4 folder inside WPF, that contains libraries only for WPF 4.0 version.

AtomForm Label Alignment for Silverlight and WPF

Silverlight-Form-Label-Alignment

AtomForm now provides following two properties,

  • LabelHorizontalAlignment property that can align the label horizontally in the form item.
  • LabelVerticalAlignment property that can align the label vertically in the form item.

Label Can now contain string or UI Element object

Rich Label Format
  1. <ns:AtomTextBox HorizontalAlignment="Stretch"
  2.                 Text="{Binding Path=ProjectName, Mode=TwoWay}" Width="Auto" >
  3.     <ns:AtomForm.Label>
  4.         <StackPanel Orientation="Horizontal">
  5.             <TextBlock>Name:</TextBlock>
  6.             <Image Source="/PrismTest;component/Images/Logo.png" Width="16" Height="16" />
  7.         </StackPanel>
  8.     </ns:AtomForm.Label>
  9. </ns:AtomTextBox>

Rich-Label-Silverlight-WPF-Form

 

Advanced Quick Form Designer

Typing Tags with all Bindings could be quite time consuming, where it involves moving items up and down, deleting and adding new Form Items. Advanced Quick Form Designer resolves all this problems by giving you state of art designer, which provides one quick grid to enter all necessary information. However the form designer works well even for existing forms, and you can generate entire new form by selecting some Type as well.

Advanced-Silverlight-WPF-Form-Designer

As you see, type of control can be changed that will represent the form item and corresponding binding property can be changed as well. Just with simple one click, you can move items up and down or delete them. You can add a new control that is defaulted to AtomTextBox at the top, you can change default control to add multiple one after another very easily. Also you can click “Generate From Type” to select any Business Object Type and generate a brand new form.

Generate-Form-From-Type-Silverlight-WPF

Selecting type will automatically generate form with its bindings.

Share
Tagged with:  

UI Atoms version 1.2.22 resolves Cascaded ComboBoxes issue in MVVM pattern. Advanced AtomForm is now capable of handling cascaded ComboBoxes with MVVM and it also integrates well with third party controls.

Recently we identified few issues with MVVM implementation in Silverlight regarding ComboBoxes. ComboBox looses its “SelectedValue” binding once the ItemsSource of ComboBox changes. This needed some workaround as well as Modifying DataForm is very painful as you may need very complex form designs in regular business applications.

1. Create Models

Lets assume we need to edit a Customer’s Country and City, as we change the Country the list of cities should change it. Problem with existing ComboBox and DataForm is, as soon as list of cities changes, ComboBox’s SelectedValue binding vanishes. So lets create Customer Model first.

 

MVVM-View-Models

Each of properties in CustomerViewModel raises PropertyChanged event for corresponding properties when modified.

When selected customer changes, SelectedCountry also changes and which changes Cities property, so in drop down we can display the list of cities of selected country.

Important:

Your SelectedCountry property, where you need Change of Selection event must not raise PropertyChanged event in “set” method as shown below…, however you may turn it off or on based on your UI behavior. WPF has no problem but Silverlight has issues and it works better if PropertyChanged event is not raised.

Selected Country Property
        public Country SelectedCountry
        {
            get
            {
                return _SelectedCountry;
            }
            set
            {
                _SelectedCountry = value;
                //if (PropertyChanged != null)
                //    PropertyChanged(this, new PropertyChangedEventArgs("SelectedCountry"));
                if (_SelectedCountry != null)
                {
                    Cities = _SelectedCountry.Cities;
                }
            }
        }

2. Create Master View

Master View control declares grid with two columns, left side displaying list of customers and on right side displaying details of the selected customer.

MainPage Master View Control
<UserControl x:Class="PrismTest.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ns="http://uiatoms.neurospeech.com/silverlight"
    xmlns:local="clr-namespace:PrismTest"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <local:ViewModelLocator x:Key="locator"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="400" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <ListBox
            DisplayMemberPath="Name"
            x:Name="list"
            SelectedItem="{Binding ViewModel.SelectedCustomer,Source={StaticResource locator}, Mode=TwoWay}"
            ItemsSource="{Binding ViewModel.Customers,Source={StaticResource locator}}" />
        <local:CustomerView
            Grid.Column="1" />
        <ns:AtomTraceView
            Grid.Row="1" Grid.ColumnSpan="2"/>
    </Grid>
</UserControl>

Lets analyze Bindings,

  1. ListBox’s ItemsSource is bound to ViewModel.Customers which returns list of available customers.
  2. ListBox’s SelectedItem is bound (two way) to ViewModel.SelectedCustomer.
Customer View Control
<UserControl x:Class="PrismTest.CustomerView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:ns="http://uiatoms.neurospeech.com/silverlight"
    xmlns:local="clr-namespace:PrismTest"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <local:ViewModelLocator x:Key="locator"/>
    </UserControl.Resources>
    <ns:AtomForm DataContext="{Binding ViewModel.SelectedCustomer,Source={StaticResource locator}}">
        <ns:AtomTextBox Text="{Binding Name, Mode=TwoWay}"
                        ns:AtomForm.Label="Name:" />
        <ns:AtomComboBox ns:AtomForm.Label="Country:"
                         SelectedValuePath="CountryID"
                         DisplayMemberPath="Name"
                         ItemsSource="{Binding ViewModel.Countries,Source={StaticResource locator}}"
                         SelectedItem="{Binding ViewModel.SelectedCountry,Source={StaticResource locator}, Mode=TwoWay}"
                         SelectedValue="{Binding CountryID, Mode=TwoWay}"
                         />
        <ns:AtomComboBox ns:AtomForm.Label="City:"                          
                         SelectedValuePath="CityID"
                         DisplayMemberPath="Name"
                         ItemsSource="{Binding ViewModel.Cities,Source={StaticResource locator}}"
                         SelectedValue="{Binding CityID, Mode=TwoWay}"
                         />
    </ns:AtomForm>    
</UserControl>

Lets analyze the bindings,

  1. AtomForm’s DataContext is bound to SelectedCustomer of ViewModel, which comes from SelectedItem of Parent Control
  2. AtomTextBox’s  Text is bound to Name (of AtomForm’s DataContext’s binding) with Mode=TwoWay
  3. AtomComboBox
    1. ItemsSource is bound to ViewModel.Countries which returns list of countries.
    2. SelectedValue is bound to CountryID (of AtomForm’s DataContext’s binding) with Mode=TwoWay
    3. SelectedItem is bound to ViewModel.SelectedCountry, which triggers change of SelectedCountry property on ViewModel which changes list of cities.
  4. AtomComboBox (this is the one that’s tricky, normal ComboBox does not work here)
    1. ItemsSource is bound to ViewModel.Cities which returns list of cities of SelectedCountry.
    2. SelectedValue is bound to CityID (of AtomForm’s DataContext’s binding) with Mode=TwoWay

 

3. Cascaded ComboBox

You can see that the cascaded ComboBox work well with AtomForm and AtomComboBox and its easy to design AtomForm with MVVM with so much less code then that of DataForm and ComboBoxes.

Form

Please download the latest version of UI Atoms 2010 suite to try MVVM + AtomForm + Cascaded ComboBoxes.

Share
Tagged with:  

This tutorial outlines how to customize UI Atoms’ AtomForm appearance and layout simply by customizing its ItemContainerStyle.

AtomForm is derived from ItemsControl, and ItemsControl declares ItemContainerStyle which can customize the template of individual items that are being displayed. UI Atoms give you complete freedom of how to change your look and feel very easily by just adding a simple template in your resource dictionary.

 

Create New Item Container Style

To do this, open your xaml page in the Expression Blend and right click on the AtomForm. And choose Edit Additional Templates, and Select Edit Generated Item Container (ItemContainerStyle) and then click on “Edit a copy…”

SelectItemContainerStyle

Then choose a location to keep your style in,

ChooseStyle

Once the style editor is open, right click on “Style” and click on “Edit Template” and then click on “Edit Current”

ChooseCurrent

Now you will see the Item Container Style’s current Form Item template. Where you can change the colors and layout, for example, we have modified the Vertical Layout of “PART_Label” field as Top in this figure below.

ChangeLayout

Share
Tagged with:  

Enabling Tracing in Silverlight with UI Atoms

On June 19, 2010, in C#, by Akash Kava

UI Atoms 2010 v1.9 update now includes Trace API for developers to log information on screen just like normal .NET application.

Diagnostics Trace API

Microsoft .NET provided Trace API to help in troubleshoot problems which is of great help at time of development. But Silverlight developers are disappointed for not being able to trace in Silverlight apps. However running apps on multiple platform isn’t quite easy, and different user experiences on different platforms raise unexpected issues. Such issues are difficult to resolve as deployed client computer may not have development tools available to troubleshoot and see application logs.

Trace.WriteLine(“ Hello World “);

We sure miss Trace in Silverlight, so we decided to add similar diagnostics API in Silverlight.

Trace Viewer

In Silverlight, as it runs inside a browser, there is no way to see any trace information not only this, on different platforms like Mac, it may be too difficult for no technical user to install and enable remote debugging.

So we decided to include a visual component that can be put anywhere on screen, just like “Output” pane in visual studio. Its developer’s choice to fit the Trace Viewer. Its pretty simple Text View control, where in you can see lines of log automatically scrolling down as log grows.

AtomTraceView

UI Atoms’s AtomTraceView control works well with Silverlight as well as WPF, in WPF it uses inbuilt Trace functionality and displays trace information to user, and in Silverlight we have added custom API, that is used to display Trace information. Syntax is pretty simple.

<Grid>
   <Grid.RowDefintions>
       <RowDefinition/>
       <RowDefinition Height="200"/>
   <Grid.RowDefintions>

   <MyUserControl/>

   <AtomTraceView Grid.Row="1"/>

<Grid>

This way you can include AtomTraceView at the bottom of your page and it will display all traces programmed by the developer.

Limited API

However, .NET Trace API is very huge, and it is extensible, but Trace API offered by UI Atoms as of now is very limited, not by the design but by implications, Silverlight itself is very limited platform, this is just an Add-on for users to troubleshoot their apps.

Trace Statements in Silverlight

In order to write Trace statements, you have to import following namespace,

using NeuroSpeech.UIAtoms.Core;

Then you can write following statements and they will appear in AtomTraceView Control.

AtomTrace.WriteLine(" Hello World ");

AtomTrace.WriteLine( exception.ToString() );

AtomTrace.WriteLine( string.Format("{0},{1} Coordinates", x, y) );

 

The AtomTrace class exists for both Silverlight and WPF, so it becomes easier to write your logs with AtomTrace instead of Trace, so your code can be shared on both Silverlight as well as WPF.

Trace and Multithreading

Trace statements can be accessed by thread in Silverlight app, however the sequence in which it will appear can not be guaranteed because it depends upon the processor and scheduling algorithm used in thread pool of Silverlight application.

Custom Trace Listener

Just similar to .NET, we have included  AtomTraceListener class, which you can derive and customize trace information according to your need as well as it has Traced event, which you can implement and get trace notifications anywhere..

 

Future of Trace API in Silverlight

When Trace API will be included by Microsoft in future edition of Silverlight, we may plan to remove Trace API, to be consistent with the Silverlight development workflow, this API has been enabled only to write shared code between WPF and Silverlight environment. However otherwise, we plan to make tracing more rich with UI Atoms. But for now, it is very helpful for everyone.

Live Demo

Click Here to see live demo of Tracing in Silverlight.

Click Here to download demo version of UI Atoms 2010.

Share
Tagged with:  

Scientific calculations often require measurement unit conversion and demand high accuracy. Although it may be very easy to google around the web and get some formula, however when we looked into SI units and its Unit Guide, then we realized that even units with same name have little different value in different countries and continents.

So we decided to bring them all into User Interface control for WPF and Silverlight.

  1. Which allows Developer to adhere to one standard unit.
  2. Which allows users to choose unit of their own choice.
  3. See the conversion while editing the value.

MeasurementControlPart1

 

The following sample code displays how to use these unit converters in Silverlight and WPF.

Properties

Each of the measurement unit converter controls has four properties as mentioned below.

DisplayValue Property:

This is the editable value displayed in the text box, and user can directly modify this value by either using up/down arrow buttons or by typing in the value. The display value works in conjunction with the type of unit that is selected in Display Unit ID property.

DisplayUnitID Property:

Every measurement unit has different ID assigned by our developers to uniquely identify alpha numeric ID within the set of units. For example, meter and centimeter are IDs of Length. However you do not have to remember these IDs, when you edit your UI in Visual Studio, you can configure these IDs in the property editor. End user can visually modify Display Unit in order to retrieve and enter value in the desired unit.

ValueUnitID Property:

The DisplayUnitID is attached to DisplayValue, similarly the underlying actual value is attached with ValueUnitID property. This Unit ID is usually set to a constant throughout the lifetime of the application and is already defaulted to SI unit. e.g. for Length, it is set to meter. We recommend you to change this only if your base unit requirement is something different then SI unit. This unit can not be changed by end user it can only be programmed in the code at design time.

Value Property:

The value property is something which you are interested saving in the database and use it as base value. This is the converted value of unit ValueUnitID specified from display value of display unit.

Example:

In the first control in the above picture, Display Value is 100, Display Unit is Fathom, Value Unit is meter, so converted value in meter is 182.8804.

Live Sample:

Click here to view live sample in Silverlight.

Download Demo:

Click here to download the demo version of UI Atoms.

Share
Tagged with:  

Advanced Data Form with UI Atoms on WPF and Silverlight

On June 1, 2010, in C#, by Akash Kava

Building line of business applications for over years, we realized that the Silverlight DataForm offers very small subset of features that are needed in the long run. We figured out the problem with form based applications, that frustrates developers. That is “Change Management”.

Although WPF/Silverlight does offer very customizable UI designing platform but when we go on the field to develop ling of business applications, we realize that initial development hardly takes any time but maintenance is very difficult.

Lets review the designing problems of panels such as Grid, StackPanel, Canvas etc.

StackPanelGridChallenges

Standard Form Design

Lets review standard form design that is expected, this is the layout that can not be made except canvas panel because there is no way we can support variable columns per row. If you notice, first two rows have 3 columns equally placed and last 2 rows have two columns equally placed. Every field has description at the bottom and red required asterisk (*).

StandardFormDesign

Initial Form Design

The first draft of UI in any application is very simple and we probably do it in minutes.

CustomerRequest

Changes Requested

But the bigger problem always comes later on when changes are requested.

TypicalChanges

Atom Flexible Grid

This is the reason we created “AtomFlexibleGrid” which supports variable columns per row as displayed in the picture above. You can see that form and the flexible grid have a property called “RowLayout” which accepts comma separated cell values to be displayed per row. As displayed in the example below.

FlexibleGrid

This is very helpful in quick design, but this also way to easy to manage when changes are requested.

  • Intelligent Flow Layout with ability share multiple items in single row.
  • No attributes required on any child items.
  • Comma Separated “RowLayout” instantly renders variable column grid.
  • E.g. 3,2,1 = 3 cells in first row, 2 cells in 2nd row and 1 cell in 3rd row with automatic spanning.

Benefits of Atom Flexible Grid over Canvas, Grid and Stack Panel

  • Atom Form children are similar to Wrap Panel children, but Wrapping is completely customized via simple attributes.
  • Its easy to move items around without changing lots of attributes, Grid is very powerful but changing grid children can be huge pain.
  • Canvas is very easy to operate, but needs a powerful designer, once again changing layout can be very tedious job.

Form Field Layout

FormFieldLayout

This is how individual components of Form Field are positioned within the Form Field. Collapsible panels are only visible if the content is provided. However in future more of such components will be available in Form Field to standardize the fields.
In next slide, you will see how the fields are positioned in the Form.

Change Management

Changing layout is extremely simple, as you can simply move your items up and down and change “RowLayout” text field to quickly review how it will look. No tedious drag and drop and no typing.

Live Form Demos

Click here to see live UI Atoms form demos for Silverlight.

Click here to download UI Atoms form demos for WPF.

Share
Tagged with:  

Here at NeuroSpeech, we figured out the problem with forms based business applications that frustrates developers and change management is not only time consuming but its quite boring job to do.

Although WPF/Silverlight does offer very customizable UI designing platform but when we go on the field to develop ling of business applications, we realize that initial development hardly takes any time but maintenance is very difficult.

AtomForm has been designed to offer a standard rich business class user interface along with various advanced validation methods and the change management is very easy as “AtomFlexibleGrid” offers simple row layout concept that is offered nowhere today.

Share
Tagged with: