如何使用datepicker控件或wpf中的任何其他控件组合(文本框,图像和日历)以MM / YYYY格式显示日期

时间:2018-02-16 11:47:35

标签: c# wpf

我已经创建了2个依赖属性IsMonthYear和DateFormat.I 我找到的只有两个属性的两个类不是一个有效的解决方案。有没有更好的方法来显示MM / yyyy格式的datepicker并且还只打开一个月份和年份的日历。

<DatePicker Grid.Column="0"
        local:DatePickerCalendar.IsMonthYear="True" 
        local:DatePickerDateFormat.DateFormat="MM/yyyy"
        Name="FromDate_Picker"
        Width="Auto"
        Margin="38,0,0,0"
        HorizontalAlignment="Left"
        VerticalAlignment="Bottom"
        KeyboardNavigation.TabIndex="1"
        Padding="0"
        Text="MM/yyyy"
        SelectedDate="{Binding RelativeSource={RelativeSource FindAncestor,
                       AncestorType={x:Type Window}},
                       Path=DataContext.OutageStartDate,
                       StringFormat='MM yyyy',
                       Mode=TwoWay}"
        Style="{DynamicResource supplyDisruptiondDatePicker}"></DatePicker>

0 个答案:

没有答案