0

I have a Calendar control made to drop down when needed, but I have these great big greay area on both sides.

I have tried everything I possibly can, but I can't seem to get rid of the grey area on both sides of a calendar.

enter image description here

This is the XAML,

<DockPanel Grid.Row="0" Grid.Column="8" Height="25">
     <Menu DockPanel.Dock="Top" Height="25" Width="100">
          <MenuItem Header="calender" Height="25" Width="100" >
               <Calendar Name="CalenderSelect"
                    SelectionMode="MultipleRange" 
                    SelectedDatesChanged="Calendar_OnSelectedDatesChanged"
                    Width="192">
               </Calendar>
          </MenuItem>
     </Menu>
</DockPanel>

My second question, is this the correct way to create a drop down control with a calendar inside it. Or am I doing this wrong, any help would be much appreciated.

KyloRen
  • 2,691
  • 5
  • 29
  • 59

1 Answers1

1

First of all, from my point of view to use a menu is a bad idea to create a drop down control. You can do something similar and easier with a button.

However if you want to use the MenuItem control, you have to change the MenuItem.ItemsTemplate in order to reduce margins and remove background color:

 <Menu DockPanel.Dock="Top" Height="25" Width="100">
    <MenuItem  Header="calender" Height="25" Width="100" AutomationProperties.IsColumnHeader="True" >
        <MenuItem.Items>
            <Calendar Name="CalenderSelect" SelectionMode="MultipleRange" >  </Calendar>
        </MenuItem.Items>
        <MenuItem.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Margin="-35,-5,-50,-5" Background="{x:Null}"></StackPanel>
            </ItemsPanelTemplate>
        </MenuItem.ItemsPanel>                   
    </MenuItem>
 </Menu>

I hope this can help you.

ganchito55
  • 3,559
  • 4
  • 25
  • 46
  • Thanks, that did the trick. However, what would you suggest in place of the menu item for a drop down calendar? – KyloRen Dec 11 '16 at 12:19
  • It depends if you want only to show an item or more, [here](http://stackoverflow.com/questions/8958946/how-to-open-a-popup-menu-when-a-button-is-clicked) you can see more about button with menuItem – ganchito55 Dec 11 '16 at 13:07