ComponentOne DateTimeEditors for UWP
C1DateSelector Help / C1DateSelector Task-Based Help / Creating a C1DateSelector Control in Code
In This Topic
    Creating a C1DateSelector Control in Code
    In This Topic

    This topic will walk you through creating a C1DateSelector control and applying some basic styling to the control via code.

    Follow these steps:

    1. Open MainPage.xaml if it isn't already open and locate the <Grid> </Grid> tag set. Edit the markup so that it resembles the following markup:
    XAML
    Copy Code
    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" x:Name="LayoutRoot">
    </Grid>
    
    1. Right-click your page and select View Code from the list to switch to code view.
    1. Add the following namespaces to your application:
    C#
    Copy Code
    using C1.Xaml;
    

    Visual Basic
    Copy Code
    Imports C1.Xaml
    
    1. Insert the following constructor just below the InitializeComponent() method:
    C#
    Copy Code
    C1DateSelector c1dateselect1 = new C1DateSelector();
    

    Visual Basic
    Copy Code
    Dim c1dateselect1 As C1DateSelector = New C1DateSelector
    
    1. Add the following code inside the constructor to control the width and height of the C1DateSelector:
    C#
    Copy Code
    c1dateselect1.Height = 55;
    c1dateselect1.Width = 350;
    
    Visual Basic
    Copy Code
    c1dateselect1.Height = 55
    c1dateselect1.Width = 350
    
    1. Insert the final line of code to display the C1DateSelector:
    C#
    Copy Code
    LayoutRoot.Children.Add(c1dateselect1);
    
    Visual Basic
    Copy Code
    LayoutRoot.Children.Add(c1dateselect1)
    
    1. Run your application. The C1DateSelector control should resemble the following image:
    See Also