UXGridView: Visability UXMenuItem

3 replies. Last post: November 3, 2011 4:53 AM by Handy Surya
Tags :
  • New Discussion
  • New Question
  • New Product Feedback

Hi

I have added a new UXMenuItem to the UXGridViewContextMenuStyle in blend (see DuplicateRowCommand).

<Style x:Key="UXGridViewContextMenuStyle" TargetType="Intersoft:UXGridViewContextMenu">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Intersoft:UXGridViewContextMenu">
                <Grid x:Name="RootElement">
                    <Intersoft:UXContextMenu x:Name="ContextMenuElement" IsOpen="{TemplateBinding IsOpen}">
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.SortAscending" Header="{Binding ContextMenu_SortAscending, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/sort_az_ascending2.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.SortDescending" Header="{Binding ContextMenu_SortDescending, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/sort_az_descending.png"/>
                        <Intersoft:UXSeparator x:Name="GroupSeparator"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.GroupByBox" Header="{Binding ContextMenu_GroupByBox, Source={StaticResource GridViewResource}}" IsCheckable="True"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Group" Header="{Binding ContextMenu_Group, Source={StaticResource GridViewResource}}"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Ungroup" Header="{Binding ContextMenu_Ungroup, Source={StaticResource GridViewResource}}"/>
                        <Intersoft:UXSeparator x:Name="EditingSeparator"/>
                        <Intersoft:UXMenuItem x:Name="CopyRowItem" Command="local:UXGridViewContextMenuCommands.CopyRow" Header="{Binding ContextMenu_CopyRow, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/clipboard_add.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Edit" Header="{Binding ContextMenu_Edit, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/pencil.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Delete" Header="{Binding ContextMenu_Delete, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/delete.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Update" Header="{Binding ContextMenu_Update, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/check.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.Cancel" Header="{Binding ContextMenu_Cancel, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/delete.png"/>
                        <Intersoft:UXMenuItem Visibility="{Binding ElementName=CopyRowItem,Path=Visibility}" Command="{Binding DuplicateRowCommand}" CommandParameter="{Binding SelectedItem}" Header="Duplizieren" Icon="/QMS;component/Assets/Images/16/element_copy.png"/>
                        <Intersoft:UXSeparator x:Name="BatchUpdateSeparator"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.SaveChanges" Header="{Binding ContextMenu_SaveChanges, Source={StaticResource GridViewResource}}" Icon="/Intersoft.Client.UI.Data;component/Resources/savechanges.png"/>
                        <Intersoft:UXMenuItem Command="local:UXGridViewContextMenuCommands.RejectChanges" Header="{Binding ContextMenu_RejectChanges, Source={StaticResource GridViewResource}}" Icon="/Intersoft.Client.UI.Data;component/Resources/rejectchanges.png"/>
                    </Intersoft:UXContextMenu>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


It works great. I have only the problem that the menu item is always visible (see attached picture).

A simple solution would be a visability-binding to CopyRow. But I am not so happy about this...

<Intersoft:UXMenuItem x:Name="CopyRowItem" Command="local:UXGridViewContextMenuCommands.CopyRow" Header="{Binding ContextMenu_CopyRow, Source={StaticResource GridViewResource}}" Icon="/QMS;component/Assets/Images/16/clipboard_add.png"/>
<Intersoft:UXMenuItem Visibility="{Binding ElementName=CopyRowItem,Path=Visibility}" Command="{Binding DuplicateRowCommand}" CommandParameter="{Binding SelectedItem}" Header="Duplizieren" Icon="/QMS;component/Assets/Images/16/element_copy.png"/>

Can I find out which context menu (row or header) appears to control the visibility of items?

Thanks.

Regards

Michael

 

 

All times are GMT -5. The time now is 10:16 AM.
Previous Next