The easiest way I could find was to create a UserControl and then place a DatePicker
and a TimePicker
side by side in a grid.
In the control's code-behind, declare two DateTime
variables that hold the desired data:
public class MyControl
{
public DateTime MyDate { get; set; }
public DateTime MyTime { get; set; }
...
In the control's xaml, include these namespaces:
xmlns:Ctls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:ImplCtls="clr-namespace:Microsoft.LightSwitch.Presentation.Implementation.Controls;assembly=Microsoft.LightSwitch.Client.Internal"
The control's definition:
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Ctls:DatePicker Grid.Row="0" Grid.Column="0"
SelectedDateFormat="Short"
SelectedDate="{Binding Path=MyDate, ElementName=MyUserControl, Mode=TwoWay}"/>
<ImplCtls:BaseTimePicker Grid.Row="0" Grid.Column="1"
Value="{Binding Path=MyTime, ElementName=MyUserControl, Mode=TwoWay}"/>
</Grid>
Hope this helps out someone...