none
Не полностью по высоте отображается элемент управления "Календарь" в .Net 4 WPF проекте RRS feed

  • Вопрос

  • Приветствую. Есть форма, Календарь в которой отображается не полностью:

    Весь вечер играюсь с кодом и параметрами Height, единственный вариант, когда календарь отображается на полную высоту:

    это ситуация, когда MinHeight жёстко прописан на ту строку, из которой вызывается Expander (Строка помечена как TimeRow),

    но тогда при открытии формы есть куча белого и незаполненного пространства между expander'ами.

    XAML код ниже. Проблема  в моём коде или где-то в .Net?

    Проект на Net4Client Profile, WPF, Studio 2012 на Windows 2008R2SP1 со всеми установленными обновлениями и .net4.5 в том числе.

    Спасибо за помощь, советы и подсказки

    <Window x:Class="WPFAlarmer.EditSnoozer"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="EditSnoozer"  SizeToContent="WidthAndHeight" ResizeMode="NoResize">
        <Grid Name="MainGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="150"/>
                <ColumnDefinition Width="50"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition Name="TimeRow"/>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
    
            </Grid.RowDefinitions>
    
            <TextBlock Name="LabelName" Grid.Column="0" Grid.Row="0" TextAlignment="Center" TextWrapping="Wrap">Название напоминания</TextBlock>
            
            <TextBox x:Name="EditSelectedSnoozerName" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" TextWrapping="Wrap" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" TextAlignment="Center" Text="Имя" TextChanged="WindowNameChange" MouseEnter="SelectAll" MouseMove="SelectAll" Tag="SnoozerName"/>
    
            <TextBlock Name="LabelTime" Grid.Column="0" Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" >Время</TextBlock>
            <TextBlock Name="EditSelectedSnoozerTime" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" TextAlignment="Center"></TextBlock>
            
                <Expander Header="Настройки времени" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" >
    
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="175"/>
                        </Grid.RowDefinitions>
    
                        <Grid Name="WeekDays" Grid.Column="1" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
    
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
    
                            <CheckBox Name="Monday" Grid.Row="0" Grid.Column="1" Content="Понедельник"></CheckBox>
                            <CheckBox Name="Tuesday" Grid.Row="1" Grid.Column="1"  Content="Вторник"></CheckBox>
                            <CheckBox Name="Wednesday" Grid.Row="2" Grid.Column="1"  Content="Среда"></CheckBox>
                            <CheckBox Name="Thursday" Grid.Row="3" Content="Четверг"></CheckBox>
                            <CheckBox Name="Friday" Grid.Row="4"  Content="Пятница"></CheckBox>
                            <CheckBox Name="Saturday" Grid.Row="5"  Content="Суббота"></CheckBox>
                            <CheckBox Name="Sunday" Grid.Row="6"   Content="Воскресенье"></CheckBox>
    
                        </Grid>
                            
                        <Calendar  Name="Calendar" DisplayMode="Month" SelectionMode="MultipleRange" SelectiveScrollingGrid.SelectiveScrollingOrientation="None" ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.Column="0"/>
                        
                    </Grid>
                </Expander>
            
            <Expander Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Header="Настройки уведомлений">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="139"/>
                        <ColumnDefinition Width="49"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
    
                    <TextBlock Name="LabelSound" Grid.Column="0" Grid.Row="0" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Звук</TextBlock>
                    <CheckBox x:Name="EditSelectedSnoozerSound" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    
                    <TextBlock Name="LabelSoundFile" Grid.Column="0" Grid.Row="1" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Звуковой файл</TextBlock>
                    <TextBlock Name="EditSelectedSnoozerSoundFile" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                    <Button x:Name="EditSelectedSnoozerSoundFileButton" Grid.Column="2" Grid.Row="1" Content="Звук"/>
    
                    <TextBlock Name="LabelText" Grid.Column="0" Grid.Row="2" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Текст</TextBlock>
                    <CheckBox x:Name="EditSelectedSnoozerText" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    
                    <TextBlock Name="LabelTextMessage" Grid.Column="0" Grid.Row="3" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Сообщение</TextBlock>
                    <TextBox x:Name="EditSelectedSnoozerTextMessage" Grid.Row="3" VerticalAlignment="Center"  Grid.ColumnSpan="2" TextAlignment="Center" Grid.Column="1" MouseEnter="SelectAll" MouseMove="SelectAll" Tag="TextMessage"/>
    
                    <TextBlock Name="LabelIcon" Grid.Column="0" Grid.Row="4" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Иконка</TextBlock>
                    <Button x:Name="EditSelectedSnoozerIcon" Grid.Column="2" Grid.Row="4" Content="Иконка" />
                </Grid>
            </Expander>
    
            <TextBlock Name="LabelEnabled" Grid.Column="0" Grid.Row="4" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Включен</TextBlock>
            <CheckBox x:Name="EditSelectedSnoozerEnabled" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
    
            <TextBlock Name="LabelCanDelete" Grid.Column="0" Grid.Row="5" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Можно удалить</TextBlock>
            <CheckBox x:Name="EditSelectSelectedSnoozerCanDelete" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
    
            <Button Name="DeleteSelectedSnoozer" Grid.Column="0" Grid.Row="6" Click="DeleteSelectedSnoozer_Click">Удалить</Button>
            <Button Name="SaveSelectedSnoozer" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="2" Click="UpdateSnoozerButton" >Сохранить</Button>
    
        </Grid>
    </Window>
    

    21 сентября 2012 г. 21:34

Ответы

Все ответы

  • Попробуйте в <RowDefeniton> поставить высоту Auto
    • Предложено в качестве ответа Abolmasov Dmitry 24 сентября 2012 г. 7:17
    • Помечено в качестве ответа Abolmasov Dmitry 27 сентября 2012 г. 13:46
    23 сентября 2012 г. 18:22
  • В определение строки грида в которой располагается Expander добавил выстоту Auto, в описании грида, который содержит сам календарь убрал определение высоты:

    <Window x:Class="WpfApplication4.MainWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="EditSnoozer"  SizeToContent="WidthAndHeight" ResizeMode="NoResize">
        <Grid Name="MainGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="150"/>
                <ColumnDefinition Width="50"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition Name="TimeRow" Height="Auto"/>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Name="LabelName" Grid.Column="0" Grid.Row="0" TextAlignment="Center" TextWrapping="Wrap">Название напоминания</TextBlock>
            <TextBox x:Name="EditSelectedSnoozerName" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" TextWrapping="Wrap" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" TextAlignment="Center" Text="Имя" TextChanged="WindowNameChange" MouseEnter="SelectAll" MouseMove="SelectAll" Tag="SnoozerName"/>
            <TextBlock Name="LabelTime" Grid.Column="0" Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" TextWrapping="Wrap" >Время</TextBlock>
            <TextBlock Name="EditSelectedSnoozerTime" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" TextAlignment="Center"></TextBlock>
            <Expander Header="Настройки времени" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" >
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid Name="WeekDays" Grid.Column="1" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <CheckBox Name="Monday" Grid.Row="0" Grid.Column="1" Content="Понедельник"></CheckBox>
                        <CheckBox Name="Tuesday" Grid.Row="1" Grid.Column="1"  Content="Вторник"></CheckBox>
                        <CheckBox Name="Wednesday" Grid.Row="2" Grid.Column="1"  Content="Среда"></CheckBox>
                        <CheckBox Name="Thursday" Grid.Row="3" Content="Четверг"></CheckBox>
                        <CheckBox Name="Friday" Grid.Row="4"  Content="Пятница"></CheckBox>
                        <CheckBox Name="Saturday" Grid.Row="5"  Content="Суббота"></CheckBox>
                        <CheckBox Name="Sunday" Grid.Row="6"   Content="Воскресенье"></CheckBox>
                    </Grid>
                    <Calendar  Name="Calendar" DisplayMode="Month" SelectionMode="MultipleRange" SelectiveScrollingGrid.SelectiveScrollingOrientation="None" ScrollViewer.VerticalScrollBarVisibility="Disabled" Grid.Column="0"/>
                </Grid>
            </Expander>
            <Expander Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3" Header="Настройки уведомлений">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="139"/>
                        <ColumnDefinition Width="49"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Name="LabelSound" Grid.Column="0" Grid.Row="0" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Звук</TextBlock>
                    <CheckBox x:Name="EditSelectedSnoozerSound" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    <TextBlock Name="LabelSoundFile" Grid.Column="0" Grid.Row="1" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Звуковой файл</TextBlock>
                    <TextBlock Name="EditSelectedSnoozerSoundFile" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" TextAlignment="Center" HorizontalAlignment="Center"></TextBlock>
                    <Button x:Name="EditSelectedSnoozerSoundFileButton" Grid.Column="2" Grid.Row="1" Content="Звук"/>
                    <TextBlock Name="LabelText" Grid.Column="0" Grid.Row="2" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Текст</TextBlock>
                    <CheckBox x:Name="EditSelectedSnoozerText" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    <TextBlock Name="LabelTextMessage" Grid.Column="0" Grid.Row="3" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Сообщение</TextBlock>
                    <TextBox x:Name="EditSelectedSnoozerTextMessage" Grid.Row="3" VerticalAlignment="Center"  Grid.ColumnSpan="2" TextAlignment="Center" Grid.Column="1" MouseEnter="SelectAll" MouseMove="SelectAll" Tag="TextMessage"/>
                    <TextBlock Name="LabelIcon" Grid.Column="0" Grid.Row="4" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Иконка</TextBlock>
                    <Button x:Name="EditSelectedSnoozerIcon" Grid.Column="2" Grid.Row="4" Content="Иконка" />
                </Grid>
            </Expander>
            <TextBlock Name="LabelEnabled" Grid.Column="0" Grid.Row="4" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Включен</TextBlock>
            <CheckBox x:Name="EditSelectedSnoozerEnabled" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <TextBlock Name="LabelCanDelete" Grid.Column="0" Grid.Row="5" TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center">Можно удалить</TextBlock>
            <CheckBox x:Name="EditSelectSelectedSnoozerCanDelete" Grid.Column="1" Grid.Row="5" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" />
            <Button Name="DeleteSelectedSnoozer" Grid.Column="0" Grid.Row="6" Click="DeleteSelectedSnoozer_Click">Удалить</Button>
            <Button Name="SaveSelectedSnoozer" Grid.Column="1" Grid.Row="6" Grid.ColumnSpan="2" Click="UpdateSnoozerButton" >Сохранить</Button>
        </Grid>
    </Window>


    Для связи [mail]

    24 сентября 2012 г. 7:18