CalenderView调整UWP中的Orientation调整问题

时间:2016-09-09 06:28:01

标签: c# uwp windows-10-universal

我在Windows 10 UWP应用程序中使用CalenderView,它在Mobile View中工作正常,但我想在桌面中使用相同的设置并设置特定的宽度高度它所以它显示完美但我面临问题,如下图所示

Calener View

我的CalenderView XAML代码

<CalendarView x:Name="MyCalenderView"
              Grid.Row="1"
              Visibility="Collapsed"
              SelectedBorderBrush="#148BDF"
              CalendarItemBackground="#FFDDEBF7"
              DayItemFontSize="11"
              MonthYearItemFontSize="16"
              NumberOfWeeksInView="5"
              SelectedDatesChanged="MyCalenderView_SelectedDatesChanged">                  

         <CalendarView.CalendarViewDayItemStyle>
               <Style TargetType="CalendarViewDayItem">
                    <Setter Property="MinHeight" Value="35"/>
                    <Setter Property="MinWidth" Value="35"/>
                    <Setter Property="Margin" Value="1"/>
                    <Setter Property="Padding" Value="0,0,0,4"/>
                    <Setter Property="Template">
                           <Setter.Value>
                               <ControlTemplate TargetType="CalendarViewDayItem"/>
                            </Setter.Value>
                     </Setter>
                  </Style>
             </CalendarView.CalendarViewDayItemStyle>
       </CalendarView>

即使我尝试为高度和宽度添加固定值,但没有运气。有人可以建议我做错了吗?

1 个答案:

答案 0 :(得分:1)

根据我的要求,我找到了解决此问题的解决方法。我为CalenderView添加了MaxWidth参数,如下所示

<CalendarView x:Name="MyCalenderView"
          Grid.Row="1"
          Visibility="Collapsed"
          SelectedBorderBrush="#148BDF"
          CalendarItemBackground="#FFDDEBF7"
          DayItemFontSize="11"
          MonthYearItemFontSize="16"
          NumberOfWeeksInView="5"
          MaxWidth=320
          SelectedDatesChanged="MyCalenderView_SelectedDatesChanged">                  

     <CalendarView.CalendarViewDayItemStyle>
           <Style TargetType="CalendarViewDayItem">
                <Setter Property="MinHeight" Value="35"/>
                <Setter Property="MinWidth" Value="35"/>
                <Setter Property="Margin" Value="1"/>
                <Setter Property="Padding" Value="0,0,0,4"/>
                <Setter Property="Template">
                       <Setter.Value>
                           <ControlTemplate TargetType="CalendarViewDayItem"/>
                        </Setter.Value>
                 </Setter>
              </Style>
         </CalendarView.CalendarViewDayItemStyle>
   </CalendarView>