Hello,
Since some days I try to start my plugin's dev with some tests (i will need database connection etc, all of that is done). But the fact is that i'm pretty new to C# and xaml, so i created a xaml template using Visual Express 2013, here it is :
<UserControl x:Class="UserConnect.UILogin"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid HorizontalAlignment="Left" Height="149" Margin="51,72,0,0" VerticalAlignment="Top" Width="200">
<PasswordBox HorizontalAlignment="Left" Margin="31,61,0,0" VerticalAlignment="Top" Width="140"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="31,22,0,0" TextWrapping="Wrap" Text="Username" VerticalAlignment="Top" Width="140"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="61,86,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
</Grid>
</UserControl>
And a little class file, to start my UI :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
namespace UserConnect
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UILogin dialog = new UILogin();
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
throw new NotImplementedException();
}
public Result OnStartup(UIControlledApplication application)
{
UILogin dialog = new UILogin();
return Result.Succeeded;
}
}
}
The problem is that i can perfectly load the class in my add-ins menu, but nothing happens, not even an error message, so i don't know why it doesn't works, and i can't find the solution.
Thanks for your help.
Solved! Go to Solution.
Solved by DavidVeld. Go to Solution.
Dear Supamiu,
Please work through the Revit API getting started material, especially the 'My first Revit plugin' and DevTV tutorials:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#2
Good luck and have fun!
Best regards,
Jeremy
Just a quick look but I believe a user control should be embedded inside a
winform or WPF, I dont believe it is possible to just show it like that.
Then you can show your winform easilly
MyWinform myWinform = new MyWinForm();
myWinform.ShowDialog();
There should be your usercontrol inside...
Thx for your answers I'm going to try it today and give some feedback.@jeremytammik I've done the "my first plugin" tutorial and watched 2 videos of DevTV, but i found nothing in those tutorials that could help me to create just a simple Xaml and show it in my addin.
Too true, no XAML in there, just Windows Forms, indeed.
Thanks to David for the better explanation!
The Building Coder and one or two SDK samples do include XAML forms, though...
Cheers,
Jeremy