Would it be practical to create WPF applications without ever touching Visual Studio (or any other IDEs)? As in, coding and compiling completely within Vim and the command-line? What resources would you recommend for someone trying to do so?
It would be possible, since basically WPF is based on XAML - a variant of XML - and C# or VB.NET or another .NET language as its backend language.
The question really is whether that's practical and if it makes sense - I highly doubt it. WPF is all about visual design, e.g. totally without a visual designer (either the built-in one in Visual Studio, preferably the 2010 version; or some other visual designer), it seems a bit silly to want to program WPF....
As for resources - well, a least a text editor is a must, then definitely a few good books on WPF, and you could leverage the C# or VB.NET compiler that comes with the .NET framework.
I have found myself writing XAML in Notepad on a number of occasions where I needed to create a quick UI but couldn't load an IDE. It is really quite trivial, and almost - but not quite - as fast as using an IDE. The main advantages of an IDE such as Blend or VS.NET are in quickly getting things like colors and animations to be "just right."
Another occasion when I frequently write XAML or C# in a text editor is here on Stack Overflow. I only fire up Visual Studio when I need to test something out.
My main recommendations for creating WPF applications without an IDE are:
First you should make proper use of WPF's layout system, using appropriate panels and "Auto" sizing wherever possible. For example, if you want a stack of buttons with some space between them, create a <StackPanel>, and on each button add Margin="4" or whatever. This is good design anyway. Most beginning WPF programmers treat it like WinForms with no layout capability, which is a shame. WPF has a very powerful layout engine and it should be used. If it is, there will never be any need for graph paper or measurements. In addition, your UI will automatically adjust its layout if you change font sizes or objects are larger than expected.
Second you should use msbuild for your project unless it is ultra-simple. msbuild is installed along with NET Framework so it is always available. The file format is very easy to edit with a text editor, and it is much better than a batch file with the appropriate "csc" command because it allows you to use code-behind and is less error-prone when adding new source files.
Third keep a PowerShell command line window open separate from your editor, with a command that runs "msbuild" and then executes your application. To run your app, then just Alt-Tab to this window and hit uparrow, Enter. Some text editors have the ability to execute user-defined commands directly from within the editor and see the output, in which case this second window is not necessary.
Fourth keep a copy of cordbg or mdbg handy. Although an IDE is the ideal place to do your debugging, any debugger is better than none at all. You will find your problems much faster if you stop at breakpoints and examine variables than if you just keep editing code and re-running.
Fifth, use "ColorPad" or a similar application to select your colors for use. Just guessing and entering your best guess in hexadecimal just doesn't work very well.
For resources, I recommend you get the book "WPF Unleashed" and work through the examples. I would also read a lot of other people's XAML, such as can be found on CodePlex.
Possible, Yes. Practical No.
For production work, I would consider Microsoft Expression Blend 3. Then copy the XAML and paste it into the editor of your choice and compile from the command line.
You could download KAXAML . It's a free, lightweight editor. I found it good for learning about XAML and seeing how minor changes and tweaks can impact on an overall design.
XAML is plain old text so find a free editor (KAXAML), use it, and if you must, paste into your editor.
If you really want to go down this route, I'd recommend getting some graph (squared) paper and a sharp pencil.
Draw out your designs on that, read off the positions and type them into your editor of choice.
One benefit of this is that you're going to have a paper prototype to show people ;)
As James Keesey points out in his comment on marc_s's answer, your edit-compile-test cycle is going to be painful.
It's definitely possible. I'd say it's not practical, though.
To be honest, I do professional WPF development and I do it with the visual designer closed. I'm much more comfortable editing the XAML by hand, just like I write HTML. However, the benefits of an IDE go far beyond the visual designer. There's IntelliSense, debugging and a whole host of other invaluable features.
Really, I must question your motives. What are you trying to gain? Visual Studio Express editions fully support WPF development, so it can't, or shouldn't, be a cost issue.
The newest version (3.0) now supports the wpf template.
Just download it from: https://dotnet.microsoft.com/
Just type in console:
dotnet new wpf -o wpfHello
cd wpfHello
code .
Greetings :-)
Related
So, I'm a C++ developer poking around into C#/Xamarin (did some Silverlight back a while ago.) I'm using VS 2017, the released version. I think that the preview is acting the same.
If I try to make changes to the main (porable) project versions the XAML files, I don't get a functional form previewer, it wants to use the live viewer simulating either Android or iOS. That's a lot slower and less convenient that just previewing the layout as I go, with alignment bars and all that. I do get the form previewer if I make changes in the UWP sub-project, but of course those then don't show up.
Also, if I edit the portable XAML I get no error checking. If I edit the UWP XAML I get error checking, but that's useless for the same reason.
So that all just doesn't make sense to me. Am I missing something? Why pre-generate the dups to begin with since we shouldn't need them other than for platform specific stuff, and why do the tools not work on the ones that we have to actually use?
These issues were taken care of, as best I can tell, in preview 5, though with some fiddling about. I get intellisense and error reporting in the portable (Xamarin specific I guess) Xaml files. The new live viewer isn't as nice as the UWP/Forms one that was in the tab and provided alignment and all that. Hopefully they will get that applied to the Xamarin specific XAML files.
I have an assignment which, if I could implement it any way I wanted, would be relatively easy. Alas, there are a number of restrictions on the implementation. I need to create a Visual Studio project which uses C#.Net Windows Presentation Form (WPF) for the GUI and Visualization Toolkit (VTK) with C++ for 3D rendering. If you look that up on-line, you'll soon find something specifically designed for this--ActiViz.Net. Unfortunately, using ActiViz.Net is specifically forbidden.
I've been able to build VTK and the example projects in Visual Studio. I'm still not entirely comfortable with it, but I at least know how to do some basic rendering. WPF doesn't seem too bad on its own. But how do I combine these into a single project, with the GUI influencing the rendering? So for example, I'd use WPF to make a button that said "enlarge sphere". I'd use VTK to render a sphere, either in the same window that had the button, or in a separate window. When the user clicks the button, it will run an event method in C#. And that method will somehow tell the C++ code using VTK to make the sphere larger.
At the moment, I'm not even sure how to make a single project with both of these parts, let alone how to communicate between them. Really, the best I can think of right now is two separate programs, with the GUI program launching the 3D program, and influencing the rendering by writing out a file that the rendering program reads. Not very elegant, I know. Any better ideas?
For a long time now, I have been stuck with Windows Forms development (started with VB6, and has continued through to C# .NET 4.5), and I have pretty much hit the limit of what Windows Forms can do, both using pure .NET, and special effects with Native Code.
I have tried to learn WPF and XAML, but I get stuck right at WPF's new designer. It really seems very difficult to use in comparison to the Windows Forms designer.
I want to know if there are any alternatives to .NET's WPF designer, that are more suited to Windows Forms developers?
I like to blog about beginner articles for WPF, and there are a few in particular that may help you out:
Understanding the change in mindset when switching from WinForms to WPF
What is this "DataContext" you speak of?
A Simple MVVM Example
To summarize, the biggest difference between Winforms and WPF is that in WPF your data layer (the DataContext) is your application, while in Winforms your UI layer is your application.
To look at it another way, with WPF your application consists of the objects you create, and you use Templates and other UI objects to tell WPF how to draw your application components.
That's the opposite of WinForms where you build your application out of UI objects, and then supply them with the data needed.
Because of this, the designer isn't actually used that much since your application components are designed in code, and the designer is only needed to draw a user-friendly interface that reflects your data classes (typically Models and ViewModels)
And personally, I prefer to type all my XAML out by hand since it's faster and doesn't make as much of a mess as the drag/drop WPF designer does, although I do use the Designer on occasion to preview what my UI will look like.
So to your answer your question about if there's other WPF designers suited for WinForms developers, I would suggest that instead of looking for another designer, instead look to learn how to use WPF in the way it's meant to be used. Using WPF like it's WinForms means you miss out on much of what makes it so great :)
Well although, some people don't agree, I would also recomment to not use the VS designer. At least not to create an interface. If you may want to get a first impression of your implementation without starting the application, it's a good viewer at least as long no sophisticated things like Styles and Templates are used. But, IMHO, its drag and drop result should only be used as prototype and therefore be discarded after it's no longer needed.
Here are some reasons which are important for me not to use it.
The VS designer is working with fix margins and alignments (which is usually not necessary, if you're using the layout controls), means you have to touch many controls, if the requirements are changed. If you're deep in XAML and the WPF mechanics you can create an applications which can be modified with small effort, regarding the look and feel.
Since the designer is generating the xaml, the composition is not optimal and the UI may perform badly. I didn't measure it, it's just a feeling.
A much better alternative is MS Blend, although the start is everything else but easy. Its drag and drop result is much better that the result of the VS designer.
But it's a pretty powerful tool, which helps you to use pretty powerful elements to create a state of the art UI. I recommend to visit at least a short workshop to get an idea of its opportunities.
Back to your question, IMHO, and I think many people agree, get yourself a good book e.g. WPF Unleashed and later, if you want to know more about the details, WPF Pro. There are a lot of features which are different to Winforms. You won't get to know them by using any designer. I think that's the best approach.
Please also consider that there are many frameworks and libraries (e.g. MVVM light, WPFToolkit) out there, which are already solving some common problems. So it's not necessary to reinvent the wheel.
I know this is an old question but for the benefit of anyone else looking at this, I think I should redress the balance a bit - reading some of the other answers, I get the feeling that some of the 'don't use the designer' sentiment comes from not using it properly.
This tutorial is quite good to get you going and answers some of the criticisms in the other posts.
For instance, you can switch from the Winforms-like margin-based layout that is the default when you drop a control, to a more WPF-ish style by right-clicking and selecting 'Reset Layout'
This video covers similar ground.
I still prefer the VS2010 designer on balance - VS2013 seems to be a bit buggy when dragging and dropping onto TabItems **, (which my current project uses a lot) - but the VS2013 Document Outline view lets you move things around in that view too, which can be a real plus.
Really, though, to get the most out of WPF and xaml you need to be reasonably fluent in both the designer view and the xaml view and switching between them; if you shy away from the designer, you are missing out on something that can help you a lot.
** Edit - although this seems to have been improved in Update 3 for VS 2013, and in previews of VS14, to date I still get odd behaviour at times.
First of all, in WPF (XAML) in Visual Studio deisgner, you should always use the xaml code to build you UI and do not drag and drop you control! You need to keep your code clean. You can use Expression Blend to help you, it's more graphic oriented with drag and drop, but it's not free.
It's not a big learning curve, but I think you should learn how to do your xaml by hand instead of searching for alternative.
I've been through this process as you did. Afterwards I was teaching everyone in my company WPF. There are a couple of important lessons I have learned and everybody I know who works with WPF.
If you are working with UI controls in the code behind, .... Then you are doing it wrong. There is absolutely no need for you to deal with UI controls in the code behind.
You do not need the visual developer for clicking on it. You are much more productive by only dealing with XAML.
Use Copy/Paste. Do not trust in your typing capabilities. It will save a lot of headaches.
Think of the XAML just as a window that loks over the data. In the code behind you are changing the data. In XAML you are defining how the UI will interpret the data.
Converters are amazing. As soon as you get a key amount of Converters, your productivity will rocket Sky high. They will take over the role of the crazy amount of control eventhandlers that hide or resize, or what ever about UI,
It makes UI development fun. Especially once you find out how it likes to play along with Asyc processes. It really takes away a lot of the headaches that were caused by Winforms.
I am mainly a java programmer, using linux/os x for as long as i remember. I am extremely comfortable in emacs and usually prefer doing things through command line.
I need to create a internet explorer addon for our next project. I need to intercept url ie is about to download and if they meet certain criteria pass it to our application.
So my questions are,
How can i build a c# project through command line so i can integrate it with our current build process.
Current i have windows 2k installed in a virtual machine that i use for testing. Is there going to be any compatibility problems.
I am assuming i am going to be creating a dll and inject it to ie to intercept url's. Am i on the right track?
Here are responses to your questions:
Use the C# Command Line Compiler. MSDN has an entire section devoted to its use.
Not for an IE add-on. If you plan to do more, using some newer libraries, you may run into problems unless you're running Windows XP or later. For IE addons, 2000 should be fine.
That's the basic idea. I'd refer to the MSDN articles on creating add-ons for IE, such as this one showing how to make custom menus.
Be aware, though, that you'll have a more difficult time if you avoid using Visual Studio (or some other IDE). There is no reason not to use VS, especially since you can use the Express Edition for free. If you're doing that, you can use msbuild instead of csc directly, and it will simplify your build process (even if you build from the command line).
However, the productivity gains from a good IDE will come in handy, especially for C#.
Responses to your questions:
If you use Ant maybe this will help. If you use Maven, maybe this will help. Otherwise, I'd just use MSBuild or NAnt.
Can't say for sure. I would guess that the IE API would be the same on each of the platforms. YMMV.
I'm busy writing an IE addon at work and I'm using SpicIE. It's very straightforward and simplifies the IE API drastically.
I've read in the comments elsewhere that you're not a fan of VS. I would probably use it (or MonoDevelop/SharpDevelop if they can create .csproj) to create the .csproj that can be used as an input to MSBuild. It might save you time rather than having to learn the syntax of the file.
If you give up the IDE, you give up one of the best debuggers on the planet and the best code-completion I've ever seen. Other than the fact that it will be a new system to you, there is no reason to claim that you can develop faster in EMACS. Everything you need is in the IDE, and there are keyboard shortcuts to mostly everything.
If you computer can handle the work load, I really see no good reason not to use Visual Studio.
edit: the newest version of visual studio won't run on anything less than XP sp2, to my recollection. This is most likely because the new versions of .NET won't run on anything lower than that... which would be a huge compatibility problem.
I am looking to start working on a personal site using C#. I work as a web developer and have used VBScript previously and am using Coldfusion now at work. I use Dreamweaver for development in these languages.
I have read a lot of people recommending that you should use a MS IDE to develop in .net and that C# is the way to go in terms of the language. I would like to stick with Dreamweaver as I feel I would be taking on a bit too much to learn how to use a new IDE and a new language at the same time.
Will using something like Visual Studio help with developing in .net so much that it is worth the effort of changing from Dreamweaver?
If so which IDE would be best to learn with?
If I choose to stick with Dreamweaver is there any recommendations you can make as to how to best setup Dreamweaver for easy development?
I believe not. Dreamweaver is not a good tool for developing code. This is what you need in ASP.NET. You'll need debugging. You'll enjoy IntelliSense, and you can always open single files in Dreamweaver occasionally (which I doubt you would, anyway).
Grab Visual Studio Express 2013 for Web (which is free) and enjoy. It's a Windows app, like many other Windows apps! You don't need professional training to use it.
As someone who formerly coded PHP in Dreamweaver, I would strongly suggest the use of the Visual Studio IDE for C# ASP.NET applications. The benefits are numerous:
Intellisense - where any object, property, method, etc. that you create will automatically appear in an auto-complete box, drastically reducing syntax errors
Project templates - starting a web application from scratch is going to be very very tricky if you have to do it all via source code
Debugging - errors can be caught and debugged directly in the source code
Add-ins - my favorite being the Configuration Section Designer
I'm sure there are even more reasons, these are just the biggest ones.
If you feel comfortable using Dreamweaver for design, you can still continue to use it, but I would strongly recommend you familiarise yourself with Visual Studio Express however (it's free). Trying to learn .NET and C# using a text editor or an application like dreamweaver is feasible, but you would be making the learning process unnecessarily difficult. Visual Studio gives you syntax highlighting, intellisense, debugging, and many other features that you just aren't going to get in another IDE targeted at web design. VS is really very strongly coupled to .NET development.
I started my career as a web designer many years ago using Dreamweaver, and have gradually made the transition to software developer. Leaving tools like Dreamweaver behind has actually given me a lot more freedom in terms of working as a designer, and I find that I don't in fact need any tools for markup and css other than a text editor. You may find that abandoning a design tool like dreamweaver actually makes you a better designer; and just as well - the "design" tools in Visual Studio are absolutely useless :)
If you do decide to continue using Dreamweaver for markup, be aware that things may render differently in Visual Studio. Ignore the Visual Studio design pane entirely and just check your design in the various browsers (I'm sure you already do this).
I think you would be very disappointed with the ASP.NET support in Dreamweaver. You would be MUCH better off getting yourself a copy of Visual Studio / Web Developer (express editions are free) and doing your development there.
That said, there's no reason why you can't create your HTML and CSS in Dreamweaver, then bring those files into Visual Studio to actually put in the code. This is kind of a one-time deal though since usually once you've started splitting up your HTML into master pages and user controls/partial views, it's pretty difficult to go back and edit them again in Dreamweaver.
Visual Studio 2008 will be probably better. Not only IntelliSense, but also debugging in JavaScript can be helpfull sometimes (don't know is it included in the Express edition).
Yes, coming from the exact same situation I can tell you now it will help a great deal to walk away from Dreamweaver for your .net work. The intellisense for C# is not super great in Dreamweaver. You will find features you miss a great deal from Dreamweaver though, specifically code completion on the HTML side is much better in Dreamweaver then in VS.
Another vote for Visual Studio, with the addition that you don't have to give up Dreamweaver. You can use Dreamweaver to build a basic layout and interface design. Then use Visual Studio to realize the implementation of that design.
You will find building ASP.Net without a purpose-build IDE painful.
I'd really like to point out that "IntelliSense" is nothing new and nothing Microsoft invented by any means. IntelliSense IS code hinting with links to the Microsoft help page, which I've never needed personally. Please see that Dreamweaver does have code hinting exactly the same as Visual Studio, however is not designed to develop C# and similar languages, and for that reason alone I would not recommend trying to develop with it.
As for developing purely in HTML, CSS, and JavaScript, a plain text editor is a better choice than Visual Studio granted you don't change any of the settings. There are so many things I hate about how VS behaves while I'm writing HTML, but that's another thread. On another site.