In 16.7 there are 5 types of actions that could be added:
//Simple Property Editor will be shown
PropertyAction propertyAction = new PropertyAction("Content");
//Property Editor with '...' button will be shown
PropertyAction propertyActionWithDialogButton = new PropertyAction("Content");
propertyActionWithDialogButton.DialogOpenAction = () =>
{
MessageBox.Show("Dialog Text");
};
LinkAction linkAction = new LinkAction("Help", () =>
{
Process.Start("http://microsoft.com");
};
ShowDialogCommand showDialogCommand = new ShowDialogCommand("Dialog Text");
CommandAction commandAction = new CommandAction("Call 'Show Dialog' Command", showDialogCommand, "CommandParameterObject"))
SelectableAction selectableAction = new SelectableAction("Set Content to:");
selectableAction.Items = new Dictionary<string, object>()
{
{ "Content 1", "Test Content 1" },
{ "Content 2", "Test Content 2" }
};
selectableAction.Action = (obj) =>
{
this.ModelItem.Content.SetValue(obj);
};
public class MyCustomAction : CustomAction
{
private SuggestedActionsResources res = new SuggestedActionsResources();
public string MyCustomActionText { get; }
public ICommand ResetCommand { get; }
public MyCustomAction()
{
this.Template = res["MyCustomActionTemplate"] as ControlTemplate;
this.MyCustomActionText = "Change Content options:";
this.ResetCommand = new ResetCommandImpl();
}
private class ResetCommandImpl : ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
if (parameter is ModelItem modelItem)
{
modelItem.Content.SetValue("Content");
}
}
}
}
XAML from SuggestedActionsResources
ResourceDictionary:
<ControlTemplate x:Key="MyCustomActionTemplate">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding MyCustomActionText}"/>
<Button Width="60" Height="20" Margin="2" HorizontalAlignment="Center"
Content="Reset"
Command="{Binding ResetCommand}" CommandParameter="{Binding ModelItem}"/>
</StackPanel>
</ControlTemplate>