Message 1 of 7
WPF button execute external command

Not applicable
12-17-2015
05:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello i am having trouble with connecting WPF buttons to execute method from some another class.
I have class called TEST and it looks like this:
namespace IgorAddin { [Transaction(TransactionMode.Manual)] public class TestClass : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; TaskDialog.Show("TEST", "TEST"); return Result.Succeeded; } } }
and have WPF button like this:
<Window x:Class="IgorAddin.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="400" Width="300" ResizeMode="NoResize"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="89*"/> <ColumnDefinition Width="206*"/> </Grid.ColumnDefinitions> <Button x:Name="button" Content="TestButton" Margin="0,0,205,342" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="button_Click" Grid.ColumnSpan="2" /> </Grid> </Window>
How can i make this button execute TestClass?
It's probably easy but i am little lost here.
Thanks in advance,