Blogs

The One With

Silverlight Windows, Dialogs and more from AgCore

     

Complex controls like AgDataGrid are made up of small little parts. Often this parts are generic enough and can be reused by the user code. We introduced AgCore in 9.1 as a shared library for all our controls. In 9.2 we are surfacing some of what’s inside.

Windows and Dialogs

A window can be created either in XAML or in code and can be displayed modeless or as modal dialog.

xmlns:dxc="clr-namespace:DevExpress.AgCore;assembly=DevExpress.AgCore.v9.2"

<dxc:AgWindow x:Name="window" Title="Title">

    <sys:String>Content</sys:String>

</dxc:AgWindow>

 

private void Button_Click(object sender, RoutedEventArgs e) {

    window.Show();

}

private void Button_Click(object sender, RoutedEventArgs e) {

    window.ShowDialog();

}

private void Button_Click(object sender, RoutedEventArgs e) {

    AgWindow window = new AgWindow() { Title = "Title", Content="Content" };

    window.Show();

}

 

When a window is shown as modal, a background veil (AgVeil) with no HitTest will be created under it, giving that modality effect.

Dialogs and MessageBoxes

<dxc:AgDialog x:Name="userNameDlg" Title="Enter Name" Width="300" HorizontalContentAlignment="Stretch">

    <TextBox dxc:AgStyleManager.IsStyled="True" x:Name="userName" Margin="20"/>

</dxc:AgDialog>

 

private void Button_Click(object sender, RoutedEventArgs e) {

    userName.Text = "[Your Name]";

    userNameDlg.ShowDialog(() => {

        // Do something with user input...

    });

}

 

or

 

 

AgDialog dlg = new AgDialog() { Title = "Confirmation...", Content = "Delete current record?" };

dlg.ShowDialog(() => {

    PerformDelete();

});

Sample data entry form:

 

 

xmlns:dxl="clr-namespace:DevExpress.AgLayoutControl;assembly=DevExpress.AgLayoutControl.v9.2"

xmlns:dxr="clr-namespace:DevExpress.XtraRichEdit;assembly=DevExpress.AgRichEdit.v9.2"

<dxc:AgDialog x:Name="dataForm" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"

              Width="840" Height="600" Title="New Contact" >

    <dxl:LayoutControl VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Orientation="Vertical">

        <dxl:LayoutGroup View="GroupBox" Orientation="Vertical" Header="Info">

            <dxl:LayoutItem Label="Full Name:" VerticalAlignment="Top">

                <dxe:TextEdit x:Name="fullNameEdit" EditValue="{Binding FullName}"></dxe:TextEdit>

            </dxl:LayoutItem>

            <dxl:LayoutItem Label="Home Phone:" VerticalAlignment="Top">

                <dxe:TextEdit x:Name="homePhoneEdit"  EditValue="{Binding HomePhone}">

                    <dxe:TextEdit.Mask>

                        <dxe:MaskProperties MaskType="Simple" EditMask="(999)000-00-00"/>

                    </dxe:TextEdit.Mask>

                </dxe:TextEdit>

            </dxl:LayoutItem>

            <dxl:LayoutItem Label="Cell Phone:" VerticalAlignment="Top">

                <dxe:TextEdit x:Name="cellPhoneEdit" EditValue="{Binding CellPhone}"></dxe:TextEdit>

            </dxl:LayoutItem>

            <dxl:LayoutItem Label="DOB:" VerticalAlignment="Top">

                <dxe:DateEdit x:Name="dobEdit"></dxe:DateEdit>

            </dxl:LayoutItem>

            <dxl:LayoutItem Label="Group:" VerticalAlignment="Top">

                <dxe:ComboBoxEdit x:Name="groupEditEdit" EditValue="{Binding CellPhone}">

                    <dxe:ComboBoxEdit.Items>

                        <sys:String>Family</sys:String>

                        <sys:String>Friends</sys:String>

                        <sys:String>Co-Workers</sys:String>

                    </dxe:ComboBoxEdit.Items>

                </dxe:ComboBoxEdit>

            </dxl:LayoutItem>

        </dxl:LayoutGroup>

        <dxl:LayoutGroup View="GroupBox" Header="Notes" VerticalAlignment="Stretch">

            <dxre:RichEdit x:Name="richEdit" ActiveViewType="Draft">

            </dxre:RichEdit>

        </dxl:LayoutGroup>

    </dxl:LayoutControl>

</dxc:AgDialog>

Applying the look and feel

To help you style standard controls too look and feel like the controls from DevExpress (AgDataGrid, AgMenu, AgRichEdit etc…) we have introduced a new helper class AgSyleManager. All you have to do is choose the look and feel (Visual Style)

Buttons

 

<Button Content="Standard Button"></Button>

<Button Content="DX Button" dxc:AgStyleManager.StyleType="Button"></Button>

<Button Content="DX ToolButton" dxc:AgStyleManager.StyleType="ToolButton"></Button>

In most cases it is enough to just set the AgStyleManager.IsStyled property. The AgStyleManager will then discover the control type (if supported) and apply the default DevExpress template.

 <Button Content="DX Button" dxc:AgStyleManager.IsStyled="true">

ListBox

image

<ListBox dxc:AgStyleManager.StyleType="ListBox"></ListBox>

ComboBox

 

<ComboBox dxc:AgStyleManager.StyleType="ComboBox"/>

CheckBox

image

<CheckBox Content="Standard CheckBox"/>

<CheckBox dxc:AgStyleManager.IsStyled="True" Content="DX CheckBox"/>

 

 

TextBox

 

\

 

<TextBox Text="Standard TextBox"/>

<TextBox dxc:AgStyleManager.StyleType="TextBox" Text="DX TextBox"/>

Slider

 

<Slider Width="150"/>

<Slider dxc:AgStyleManager.StyleType="Slider"/>

 

ScrollBar

 

 

<ScrollBar Orientation="Horizontal"/>

<ScrollBar dxc:AgStyleManager.StyleType="ScrollBar" Orientation="Horizontal"/>

Cheers,

Azret

Published Jul 16 2009, 05:02 PM by Azret Botash (DevExpress)
Bookmark and Share

Comments

 

Ben Hayat said:

Azret, on your "Sample Data Entry Form", how do you bind the content of the Rich Edit to a Data Field (Blob perhaps) along the other fields as you had shown?

So, when a user is looking at or entering data for a customer, they can enter or view notes at the same time!

Thanks!

July 16, 2009 8:13 PM
 

Ben Hayat said:

Second question, looking at the Dialog window or confirmation window or comboBox, there is a shadow there. Are these shadows part of the actual control on SL screen using new SL Shading or were they done with paint program for the blog?

July 16, 2009 8:16 PM
 

Chris Walsh [DX-Squad] said:

Looking very nice Azret, can't wait :)

July 16, 2009 8:23 PM
 

Minor Bolanos said:

Please, Do not forget to Create a Tab Control.

Thanks.

July 17, 2009 10:50 AM
 

Azret Botash (DevExpress) said:

@Ben, Hi Ben :)

In 9.1 RichEdit was not bindable... for 9.2 we'll try to come up with a solution... actually it is possible even in 9.1, a custom DP will do the trick.

Shadows are part of the default look and feel for DX Styles for most controls.

July 17, 2009 2:11 PM
 

Azret Botash (DevExpress) said:

@Chris: thanks :)

July 17, 2009 2:19 PM
 

Ludo Vandenbempt said:

Fantastic, my personal feeling is that Silverlight will be the future for the User Interface Layer.

July 22, 2009 5:04 AM
 

ctodx said:

We're just about to release v2009.2 and it would be a good idea to have an "accumulator"

August 20, 2009 8:29 PM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.