Removing Default menu items from file, edit, view menus

May 1, 2010 at 6:00 AM

Hi,

How can i remove the default menu items from File Menu, Like i don't need  the New , Open Menu items, Also i need to hide the edit menu, I now how to create additional menu items or menus, but this i can't get from any posts you guys made. please advice.

 

Thanks and Regards

P P Vilsad.

Developer
May 1, 2010 at 3:18 PM

Hi Vilsad

Check out Q12 and 13 of the Calcium FAQ to see how to replace the standard menu.  If you wish to remove a particular item without doing this, you need to grab the content of the view from the region manager and manipulate it that way but I wouldn’t recommend doing that.

 

Cheers

Katka

May 1, 2010 at 7:50 PM

Hi Katka,

Thank you for the reply, i did exactly what you told and created a new menu called masters for my application. (this i mentioned before). but i don't need the file menu, edit menu and view menu, just the masters menu only. any way to remove/hide unwanted menus (& menu items).

Thanks again.

P P Vilsad

 

Developer
May 1, 2010 at 10:16 PM

Hi Vilsad,

The regions must exist if they are being used by modules, but they can still have their visibility set to collapsed. Therefore you can remove the unwanted menu items by setting the  visiblity to collapsed to those items or menus you wish to remove.  See below for an example.

                            <!-- Menu -->
                            <ContentControl x:Name="PART_ContentControl_Menu" Grid.Row="1" Grid.ColumnSpan="3"
                                        Margin="7,0,0,5" Padding="5" >
                                <StackPanel x:Name="PART_StackPanel_Menu">
                                    <!--<Controls:StandardMenu x:Name="PART_Menu" Margin="0, 0, 0, 0"  />-->

                                    <Border x:Name="Border_Menu">
                                        <Menu cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.MainMenu}">
                                            <!-- File menu. -->
                                            <MenuItem Header="File" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.File}">
                                                <MenuItem Header="New" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.FileNew}" Visibility="Collapsed"/>
                                                <MenuItem Header="Open" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.FileOpen}"/>
                                                <Separator />
                                                <MenuItem Command="ApplicationCommands.Save" />
                                                <MenuItem Command="ApplicationCommands.SaveAs" />
                                                <MenuItem Command="{x:Static Gui:ShellView.SaveAll}" />
                                                <Separator />
                                                  <MenuItem Command="ApplicationCommands.Close" />
                                                <Separator />
                                                <MenuItem Command="{Binding Source={x:Static Commands:ShellCommands.ExitApplicationCommand}}"
                                                    Header="Exit"/>
                                            </MenuItem>

                                            <!-- Edit menu. -->
                                            <MenuItem Header="Edit2" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.Edit}" Visibility="Collapsed">
                                                <MenuItem Command="ApplicationCommands.Undo" />
                                                <MenuItem Command="ApplicationCommands.Redo" />
                                                <MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.RepeatTaskCommandLogic}, Path=Command}"
                                                    Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
                                                <MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.UndoGlobalTaskCommandLogic}, Path=Command}"
                                                    Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
                                                    <MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.RedoGlobalTaskCommandLogic}, Path=Command}"
                                                        Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
                                                    <Separator />
                                                    <MenuItem Command="ApplicationCommands.Cut" />
                                                    <MenuItem Command="ApplicationCommands.Copy" />
                                                    <MenuItem Command="ApplicationCommands.Paste" />
                                                </MenuItem>

                                                <!-- View menu. -->
                                                <MenuItem Header="View" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.View}">
                                                </MenuItem>

                                                <!-- Help menu. -->
                                                <MenuItem Header="Help" Width="Auto" Height="Auto">
                                                    <MenuItem Command="{Binding Source={x:Static Commands:ShellCommands.ShowAboutBoxCommand}}"
                                                    Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
                                                </MenuItem>
                                            </Menu>
                                        </Border>

                                        <!--<Controls:StandardToolBarTray x:Name="PART_ToolBar" Margin="0, 5, 0, 0"/>-->
                                        <Border x:Name="Menu_Border" Width="Auto">
                                            <ToolBarTray cal:RegionManager.RegionName="{x:Static Calcium:RegionNames.StandardToolBarTray}">
                                                <ToolBar x:Name="ToolBar_Standard">
                                                    <Button Command="ApplicationCommands.Save"
                                                    ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}">
                                                        <Image Width="15" Height="15" Source="{x:Static m:SavePng.Source}"  />
                                                    </Button>
                                                    <Button Command="{x:Static Gui:ShellView.SaveAll}"
                                                    ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}">
                                                        <Image Width="15" Height="15" Source="{x:Static m:SaveAllPng.Source}" />
                                                    </Button>
                                                </ToolBar>
                                            </ToolBarTray>
                                        </Border>
                                </StackPanel>
                            </ContentControl>

Hope this helps.

Katka

 

May 6, 2010 at 3:38 AM

Hi,

Thank you once again for the reply, i tried the above code, but i am getting an error when building (i am using vs2010). Unkown build error, key cannot be null, Parameter name:key Line 29 Position 39, the line at the said position is

<MenuItem Command="{Binding Source={x:Static Commands:ShellCommands.ExitApplicationCommand}}" 
                                                    Header="Exit"/>
what to do, please advice
May 7, 2010 at 7:38 AM

Does calcim have any compatibility issues with VS 2010 ?

Thanks and regards

P P Vilsad

May 7, 2010 at 11:26 AM
Edited May 7, 2010 at 12:14 PM

Hi,

This is what i did inside <Application.Resources> tag, but now the program is running but nothing showing, please advice

<Style TargetType="{x:Type Controls:StandardMenu}"> 
<Setter Property="Template"> <Setter.Value>
<ContentControl x:Name="PART_ContentControl_Menu" Grid.Row="1" Grid.ColumnSpan="3" Margin="7,0,0,5" Padding="5" >
<StackPanel x:Name="PART_StackPanel_Menu"> <!--<Controls:StandardMenu x:Name="PART_Menu" Margin="0, 0, 0, 0" />-->
<Border x:Name="Border_Menu"> <Menu cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.MainMenu}">
<!-- File menu. -->

<
MenuItem Header="File" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.File}">
<
MenuItem Header="New" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.FileNew}" Visibility="Collapsed"/>
<MenuItem Header="Open" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.FileOpen}"/>
<Separator />
<
MenuItem Command="ApplicationCommands.Save" />
<
MenuItem Command="ApplicationCommands.SaveAs" />
<
MenuItem Command="{x:Static Gui:ShellView.SaveAll}" />
<Separator />
<
MenuItem Command="ApplicationCommands.Close" />
<
Separator />
<MenuItem Command="{Binding Source={x:Static Commands:ShellCommands.ExitApplicationCommand}}" Header="Exit"/>
</
MenuItem>
<!-- Edit menu. -->

<MenuItem Header="Edit" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.Edit}" Visibility="Collapsed">
<MenuItem Command="ApplicationCommands.Undo" />
<MenuItem Command="ApplicationCommands.Redo" />
<MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.RepeatTaskCommandLogic}, Path=Command}" Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
<MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.UndoGlobalTaskCommandLogic}, Path=Command}" Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
<
MenuItem Command="{Binding Source={x:Static TaskModel:TaskCommandProxies.RedoGlobalTaskCommandLogic}, Path=Command}" Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
<
Separator />
<MenuItem Command="ApplicationCommands.Cut" />
<MenuItem Command="ApplicationCommands.Copy" />
<
MenuItem Command="ApplicationCommands.Paste" />
</
MenuItem>
<!-- View menu. -->
<
MenuItem Header="View" cal:RegionManager.RegionName="{x:Static Calcium:MenuNames.View}">
</
MenuItem>
<!-- Help menu. -->
<
MenuItem Header="Help" Width="Auto" Height="Auto">
<
MenuItem Command="{Binding Source={x:Static Commands:ShellCommands.ShowAboutBoxCommand}}" Header="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}" />
</
MenuItem>
</
Menu>
</Border>
<!--<Controls:StandardToolBarTray x:Name="PART_ToolBar" Margin="0, 5, 0, 0"/>-->
<Border x:Name="Menu_Border" Width="Auto">
<ToolBarTray cal:RegionManager.RegionName="{x:Static Calcium:RegionNames.StandardToolBarTray}">
<ToolBar x:Name="ToolBar_Standard">
<Button Command="ApplicationCommands.Save" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}">
<
Image Width="15" Height="15" Source="{x:Static m:SavePng.Source}" />
</Button>
<Button Command="{x:Static Gui:ShellView.SaveAll}" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}">
<
Image Width="15" Height="15" Source="{x:Static m:SaveAllPng.Source}" />
</Button>
</ToolBar>
</ToolBarTray>
</
Border>
</StackPanel>
</
ContentControl>
</Setter.Value>
</Setter>
</
Style>