Visual Studio LightSwitch 2012 by Tim Leung

Visual Studio LightSwitch 2012 by Tim Leung

Author:Tim Leung
Language: eng
Format: epub
ISBN: 9781430250715
Publisher: Apress


Listing 11-7. Duration Editor Control

File:ApressControlsVB\DurationEditor.xaml

<UserControl

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:local="clr-namespace:ApressControlsVB"

x:Class="ApressControlsVB.DurationEditor"

mc:Ignorable="d">

<Grid x:Name="LayoutRoot" Background="White">

<local:DurationEditorInternal

Duration="{Binding Value, Mode=TwoWay}"/>

</Grid>

</UserControl>

In the code that’s shown, Visual Studio adds the local namespace when you drag the DurationEditorInternal control onto your screen. If you’re re-creating this example by directly retyping the XAML that’s shown in this book, you’ll need to make sure that you enter the correct class names.

The definition of the DurationEditorInternal control within the XAML allows you to data-bind the “normal” Duration property by specifying the binding path Value.

You’re now ready to build your ApressControls project. Save the output file (ApressControls.DLL) into a location that you can refer to later.

Tip Creating a wrapper control provides a simple, declarative way to bind a custom control to the data context. If you prefer not to create two controls, another way to achieve this is to create a custom control that includes a call to SetBinding in its constructor.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.