Skip to content

Commit

Permalink
Fix ContextMenu actions [ #52 ]
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandreu committed Aug 13, 2019
1 parent be8e801 commit 34cb113
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
40 changes: 23 additions & 17 deletions OfficeRibbonXEditor/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -395,72 +395,78 @@
<HierarchicalDataTemplate
DataType="{x:Type model:OfficeDocumentViewModel}"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal"
Tag="{Binding ElementName=Window, Path=DataContext}">
<Image Width="16" Height="16" Margin="3,0" Source="{Binding ImageSource}"/>
<TextBlock Text="{Binding Name}"/>
<StackPanel.ContextMenu>
<ContextMenu>
<ContextMenu d:DataContext="{Binding DataContext, ElementName=Window}"
DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Insert Office 2010+ Custom UI Part"
Command="{Binding DataContext.InsertXml14Command, ElementName=Window}"
IsEnabled="{Binding DataContext.CanInsertXml14Part, ElementName=Window}">
Command="{Binding InsertXml14Command}"
IsEnabled="{Binding CanInsertXml14Part}">
<MenuItem.Icon>
<Image Source="/Resources/Images/xml.png"
Width="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"
Height="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Insert Office 2007 Custom UI Part"
Command="{Binding DataContext.InsertXml12Command, ElementName=Window}"
IsEnabled="{Binding DataContext.CanInsertXml12Part, ElementName=Window}">
Command="{Binding InsertXml12Command}"
IsEnabled="{Binding CanInsertXml12Part}">
<MenuItem.Icon>
<Image Source="/Resources/Images/xml.png"
Width="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"
Height="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"/>
</MenuItem.Icon>
</MenuItem>
<Separator/>
<MenuItem Header="Save" Command="{Binding DataContext.SaveCommand, ElementName=Window}">
<MenuItem Header="Save" Command="{Binding SaveCommand}">
<MenuItem.Icon>
<Image Source="/Resources/Images/save.png"
Width="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"
Height="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Save As..." Command="{Binding DataContext.SaveAsCommand, ElementName=Window}"/>
<MenuItem Header="Close" Command="{Binding DataContext.CloseCommand, ElementName=Window}"/>
<MenuItem Header="Save As..." Command="{Binding SaveAsCommand}"/>
<MenuItem Header="Close" Command="{Binding CloseCommand}"/>
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate
DataType="{x:Type model:OfficePartViewModel}"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal"
Tag="{Binding ElementName=Window, Path=DataContext}">
<Image Width="16" Height="16" Margin="3,0" Source="{Binding ImageSource}"/>
<TextBlock Text="{Binding Name}"/>
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="Insert icons..." Command="{Binding DataContext.InsertIconsCommand, ElementName=Window}">
<ContextMenu d:DataContext="{Binding DataContext, ElementName=Window}"
DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Insert icons..." Command="{Binding InsertIconsCommand}">
<MenuItem.Icon>
<Image Source="/Resources/Images/insertPicture.png"
Width="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"
Height="{Binding Source={x:Static properties:Settings.Default}, Path=IconSize}"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Remove" Command="{Binding DataContext.RemoveCommand, ElementName=Window}"/>
<MenuItem Header="Remove" Command="{Binding RemoveCommand}"/>
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type model:IconViewModel}">
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal"
Tag="{Binding ElementName=Window, Path=DataContext}">
<Image Width="16" Height="16" Margin="3,0" Source="{Binding Image}"/>
<TextBlock Text="{Binding Id}" Visibility="{Binding IsEditingId, Converter={StaticResource InverseBooleanToVisibilityConverter}}"/>
<TextBox Text="{Binding NewId, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding IsEditingId, Converter={StaticResource BooleanToVisibilityConverter}}" KeyDown="OnChangeIdTextDown" IsVisibleChanged="OnIdTextVisible"/>
<StackPanel.ContextMenu>
<ContextMenu>
<MenuItem Header="Change ID" InputGestureText="F2" Command="{Binding DataContext.ChangeIconIdCommand, ElementName=Window}"/>
<MenuItem Header="Remove" Command="{Binding DataContext.RemoveCommand, ElementName=Window}"/>
<ContextMenu d:DataContext="{Binding DataContext, ElementName=Window}"
DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Change ID" InputGestureText="F2" Command="{Binding ChangeIconIdCommand}"/>
<MenuItem Header="Remove" Command="{Binding RemoveCommand}"/>
</ContextMenu>
</StackPanel.ContextMenu>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.5.0.*")]
[assembly: AssemblyVersion("1.5.1.*")]

0 comments on commit 34cb113

Please sign in to comment.