【问题标题】:Calendar control width is too large at initialization of usercontrol用户控件初始化时日历控件宽度过大
【发布时间】:2012-10-22 11:25:03
【问题描述】:

I have used calendar control and its display mode is year when my user control is loads then calender width s too large and doesn't appear when width is set .but when is select any month then width is set as it should 我不明白它背后的问题是什么 谁能快点帮我???

这是我的代码,选择的月份将出现在文本框的文本属性中,并且在按钮的单击事件中,我的日历控件设置为可见

  <StackPanel Grid.Row="0" Grid.Column="0" Orientation="HorizontalHorizontalAlignment="Left "Margin="4">
      <Label Content="Month: " HorizontalAlignment="Right" VerticalAlignment="Top" FontSize="15" FontWeight="DemiBold" Margin="4"/>
                <TextBox Height="23" HorizontalAlignment="Stretch" Name="SelectedMonthTextBox" VerticalAlignment="Top" Width="130" Margin="4" LostFocus="SelectedMonthTextBox_LostFocus" SelectionBrush="#FF767879"/>
                <Button Content=".." Height="20" Width="20" Margin="4" Name="button" Click="button_Click" />
            </StackPanel>
            <Calendar Grid.Row="1" Grid.Column="0" Margin="50,-8" Panel.ZIndex="100"  Name="calendar1" DisplayModeChanged="calendar1_DisplayModeChanged" DisplayDateChanged="calendar1_DisplayDateChanged" HorizontalAlignment="Left" DisplayMode="Year" Style="{StaticResource CalendarStyle}" Focusable="False" HorizontalContentAlignment="Left" VerticalAlignment="Top" />

【问题讨论】:

    标签: wpf calendar width


    【解决方案1】:

    我查看了您的代码,从您目前提供的信息来看,您所描述的没有任何变化。我认为您应该检查以下内容:

    1. calendar1_DisplayModeChanged 发生了什么
    2. 如何定义您的样式:StaticResource CalendarStyle

    如果可能,请在此处发布。我会尽快提供帮助:)

    【讨论】:

    • 在 calendar1_DisplayModeChanged 中,显示模式再次设置为 year 并且在日历样式中没有任何问题,因为我在另一个控件中使用了该样式并且它在其中工作正常。而且我仍然不明白它有什么问题......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多