WP7 silverlight toolkit 学习之DatePicker and TimePicker

阅读更多

DatePicker xaml:

                HorizontalAlignment="Left"
                Margin="36,32,0,0"
                Name="datePicker1"
                VerticalAlignment="Top"
                Width="316"
                ValueChanged="datePicker1_ValueChanged"                
                  >
               
                   
                   
               

           

cs:

 private void datePicker1_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            var date = (DateTime)datePicker1.Value;
            MessageBox.Show(date.ToString("d"));
        }

----------------------------------------------------------

timepicker xaml:

                HorizontalAlignment="Left"
                ValueChanged="timePicker1_ValueChanged"
                Margin="113,170,0,0"
                Name="timePicker1"
                VerticalAlignment="Top"
                Width="197" 
                ValueStringFormat="{}你好{0:t}"/>

cs:

  private void timePicker1_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            this.PageTitle.Text = e.NewDateTime.ToString();
        }

--------------------------

属性:ValueStringFormat:设置显示时间格式
Description:Short data format(DataPicker default)
XAML:"{}{0:d}" Sample:9/20/2010
Description:Short data format(TimePicker default)
XAML:"{}{0:t}" Sample:4:00 PM
Description:Long data format
XAML:"{}{0:D}" Sample:Monday,September 20,2010
Description:Long time format
XAML:"{}{0:T}" Sample:4:00:00 PM
Description:Explicit month/day/year fromat
XAML:"{}{0:MM-dd-yyyy}" Sample:09-20-2010
Description:Explicit 24-hour time fromat with text
XAML:"{}The 24-hour time is {0:HH:mm}."
Sample:The 24-hour time is 16:00

 

 

对于日期下的两个按钮设置图片:
(1).需先添加一个文件夹,命名为:Toolkit.Content
(2).加载图片:对应的系统目录(注意对图片的属性的修改)
(3).Content/Copy if New

你可能感兴趣的:(WP7 silverlight toolkit 学习之DatePicker and TimePicker)