locked
How to replicate Windows Phone's Calendar Today button?

    Question

  • On Windows Phone, the Calendar app has an app bar button that has today's date in it (day and month). I'd like to replicate this for use with a date picker in a Windows 8 app (to be a Universal App) and I'm looking for advice on how to achieve it. My app is using XAML.

    Thanks.

    Philip

    Sunday, June 08, 2014 8:40 AM

Answers

  • Create a button subclass with a DateTime property.

    Edit the button's template to have a circular border and a grid for the day and month, then databind the day and month to the DateTime property's Day and Month properties. Create an IValueConverter to display them in the locale-specific day and short month.

    --Rob

    • Marked as answer by Philip Colmer Saturday, June 14, 2014 8:51 AM
    Tuesday, June 10, 2014 11:01 PM
    Owner

All replies

  • What part of this do you need help with?

    You can put any control in an AppBar in a Windows Store app (but not in a Windows Phone app).

        <Page.BottomAppBar>
            <AppBar>
                <Grid>
                      <DatePicker></DatePicker>
                </Grid>
            </AppBar>
        </Page.BottomAppBar>

    (I'm assuming you meant a Windows 8.1 app and not a Windows 8 app)
    Monday, June 09, 2014 1:37 AM
    Owner
  • I wanted to reproduce this:

    where the number and month name changes to match "today". I'm guessing that, from an internationalisation perspective, it doesn't make sense to have 366 different buttons, so it would seem to be sensible to place the text there dynamically.

    Just struggling with placement and sizing :-(.

    Thanks.

    Monday, June 09, 2014 8:28 AM
  • Create a button subclass with a DateTime property.

    Edit the button's template to have a circular border and a grid for the day and month, then databind the day and month to the DateTime property's Day and Month properties. Create an IValueConverter to display them in the locale-specific day and short month.

    --Rob

    • Marked as answer by Philip Colmer Saturday, June 14, 2014 8:51 AM
    Tuesday, June 10, 2014 11:01 PM
    Owner