using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB.Structure; namespace MyFirstCommand { [TransactionAttribute(TransactionMode.Manual)] public partial class UserControl1 : IExternalCommand { public UserControl1() { InitializeComponent(); } public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { return Result.Succeeded; } private void Button1_Click(object sender, RoutedEventArgs e) { if (Hellobtn.IsChecked == true) { MessageBox.Show("Hello!"); } else if (Goodbyebtn.IsChecked == true) { MessageBox.Show("Goodbye!"); } } } }
UserControl1.cs above:
UserControl1.xaml under:
Window x:Class="MyFirstCommand.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:MyFirstCommand" mc:Ignorable="d" Height="223.5" Width="615.5"><Grid Margin="2,10,0,0"><Button x:Name="button1" Content="Click here" HorizontalAlignment="Left" VerticalAlignment="Top" Width="134" Margin="273,48,0,0" Height="28" Click="Button1_Click"/><RadioButton x:Name="Hellobtn" Content="Hello" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="185,112,0,0"/><RadioButton x:Name="Goodbyebtn" Content="Goodbye" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="430,112,0,0"/></Grid></Window>