0

I have a ComboBox where the ComboBoxItem has a Grid with a Calendar inside.

The problem is that by clicking next to month label the drop down gets closed and the ComboBox changes as shown in the figure.

Starting condition Problem

This happens only by clicking there. All the other behaviours are right.

I don't know which event creates this problem..any help is really appreciate!

This is the ComboBox xaml definition:

 <ComboBox Height="46" Width="180" Text="{mhira3D:TranslateMarkup Value1 = filteringComboBox}" Margin="0,0,8,0" IsEditable="False" Tag="../Assets/Icons/filter.svg"
                          IsReadOnly="True" Style="{DynamicResource OneItemOnlyComboBox}"
                          IsDropDownOpen="{Binding FilterConcluded}">
     <ComboBox.IsEnabled>
            <MultiBinding Converter="{StaticResource BooleanAndConverter}">
                <Binding Path="ChartViewModel.NotDbErrorOccured" />
                <Binding Path="ChartViewModel.AtLeastOneRoiSelected" />
            </MultiBinding>
     </ComboBox.IsEnabled>
     <ComboBoxItem Style="{DynamicResource ComboBoxItemNoMouseOver}">
           <Grid Width="490">
                 <Grid.ColumnDefinitions>
                       <ColumnDefinition Width="3*" />
                       <ColumnDefinition Width="5*" />
                 </Grid.ColumnDefinitions>
                 <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                 </Grid.RowDefinitions>
            <...Definition of the buttons...>
            <Viewbox Grid.Column="1" Grid.Row="0" Grid.RowSpan="4">
                     <Calendar Name="CalendarFilter" SelectionMode="SingleRange"
                               IsTodayHighlighted="True" 
                               BorderBrush="{DynamicResource StandardBorderColor}"                                          SelectedDatesChanged="Calendar_OnSelectedDatesChanged">
                               <Calendar.BlackoutDates>
                                        <CalendarDateRange Start="{x:Static local:OverallChartWindow.Tomorrow}"
                                                           End="{x:Static sys:DateTime.MaxValue}" />
                                </Calendar.BlackoutDates>
                            </Calendar>
                        </Viewbox>
                     </Grid>
                 </ComboBoxItem>
              </ComboBox>

And this is the ComboBoxItem style:

 <Style x:Key="ComboBoxItemNoMouseOver" TargetType="ComboBoxItem" BasedOn="{StaticResource {x:Type ComboBoxItem}}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ComboBoxItem">
                <Border>
                    <Grid Background="{TemplateBinding Background}">
                        <Rectangle Fill="{DynamicResource StandardBackgroundColor}" 
                                   IsHitTestVisible="False"/>
                        <Rectangle x:Name="fillColor" Fill="{DynamicResource DisabledGray}"
                                   IsHitTestVisible="False"
                                   Opacity="0" Stroke="{DynamicResource StandardBorderColor}"
                                   StrokeThickness="2" />
                        <ContentControl x:Name="contentControl"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False">
                            <ContentPresenter x:Name="contentPresenter" />
                        </ContentControl>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
ctt_it
  • 339
  • 1
  • 6
  • 22
  • When playing around with comboboxes in a grid, there's two templates you usually need to set. One is ItemTemplate and the other is CellEditTemplate. It looks like you don't have a CellEditTemplate defined. – Master Apr 28 '17 at 14:28
  • I can't understand, I'm sorry..the grid is in the ComboBoxItem. Where should I define CellEditTemplate? – ctt_it Apr 28 '17 at 14:31
  • http://stackoverflow.com/questions/3671986/wpf-combobox-different-template-in-textbox-and-drop-downlist – Master Apr 28 '17 at 14:35
  • So you'll want to define ItemTemplate and ItemContainerStyle – Master Apr 28 '17 at 14:39

0 Answers0