open wpf window in Revit as add ins
Question
I made a project using WPF and I want to open its window in Revit I trying windows form it worked but wpf not opened !!
I use this
public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
IDesign.MainWindow testsd = new IDesign.MainWindow();
testsd.InitializeComponent();
//MessageBox.Show("notworking");
return Result.Succeeded;
}
But it didn't work any solutions
Solution
public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
IDesign.MainWindow testsd = new IDesign.MainWindow();
//testsd.InitializeComponent();
//MessageBox.Show("notworking");
return Result.Succeeded;
}
public MainWindow()
{
InitializeComponent();
this.ShowDialog();
}
OTHER TIPS
You may want to create a WPF User Control and assign it as the Content of a WPF window in a Revit External Command, something like:
UserControl1 userControl = new UserControl1();
Window win = new Window();
win.Content = userControl;
win.Show();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow