Tree MenuItem hot fix

This commit is contained in:
Иван Ивашкин
2025-03-06 13:35:48 +05:00
parent 943f80ad8d
commit 9a2cfbb08e
2 changed files with 25 additions and 4 deletions

View File

@@ -85,6 +85,20 @@
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" /> <Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
</MenuItem.Icon> </MenuItem.Icon>
</MenuItem> </MenuItem>
<MenuItem Header="Tree"
Command="{Binding TreeCommand}"
CommandParameter="{Binding ElementName=FunctionTreeView}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Tree.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Rename"
Command="{Binding RenameCommand}"
CommandParameter="{Binding ElementName=FunctionTreeView}">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu> </ContextMenu>
</TreeView.ContextMenu> </TreeView.ContextMenu>
</TreeView> </TreeView>
@@ -136,7 +150,8 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Button Grid.Column="0" Margin="5" Content="Tree" <Button Grid.Column="0" Margin="5" Content="Tree"
Background="AntiqueWhite" Background="AntiqueWhite"
Command="{Binding TreeCommand}"/> Command="{Binding TreeCommand}"
CommandParameter="{Binding ElementName=FunctionTreeView}"/>
<Button Grid.Column="1" Margin="5" Content="Rename" <Button Grid.Column="1" Margin="5" Content="Rename"
FontSize="10" FontSize="10"
Background="HotPink" Background="HotPink"

View File

@@ -121,7 +121,7 @@ namespace StructureHelper.Windows.TreeGraph
} }
public ICommand TreeCommand public ICommand TreeCommand
{ {
get => _treeCommand ??= new RelayCommand(o => NewTree()); get => _treeCommand ??= new RelayCommand(o => NewTree(o));
} }
public ICommand RenameCommand public ICommand RenameCommand
{ {
@@ -276,9 +276,15 @@ namespace StructureHelper.Windows.TreeGraph
} }
Save(); Save();
} }
private void NewTree() private void NewTree(object parameter)
{ {
if (SelectedFuntion is null) var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
if (selectedTreeViewItem is null)
{
return;
}
var selectedTreeViewItemParent = selectedTreeViewItem.Parent;
if (selectedTreeViewItemParent is null)
{ {
return; return;
} }