Question

I hav created a lib which reads an XAML file and generates a HUD for a game. So, now anyone can use WPF projects in visual studio to design and create a simple HUD. After that the XAML file is loaded to my lib and the HUD is created using directX. Thats the basic idea of it.

Now I want to let users create the XAML file using our own GUI editor project, without creating WPF projects and copy pasting XAML files from those WPF projects for implementing the HUD. So users must be able to,

  • Open Visual Studio and create new project of project type (project template) "Easy HUD Designer" project
  • design the HUD using the visual GUI editor.
  • Build the project so that it generates an XAML file. (or the XAML could be generated/modified while the GUI is edited, just like in WPF projects)

How to do this?

I was thinking if I can do this using Visual Studio SDK, but could not find any info on creating a visual GUI editor using it. Currently I have VS2008 and VS2010.

If this is not possible or feasible, I think I should consider about creating our own HUD designing software. A completely new application. Any suggestions and info on this is also welcome.

A somewhat similar question I found : Using the visual studio wpf editor to create an gui not for windows gui

-- EDIT --

I found some hints of doing this by experimenting,

  • Create Empty C# project
  • Add Presentation Core, Presentation Framework and Windows Base to References
  • Set project type to library ( so that building the project will not give build errors )
  • Add XAML files. ( i copied an XAML file and removed the x:Class="bla bla.." attribute from the window tag. )

This thing can be used as the project template prototype. But I would also like to control what is shown on the ToolBox at the time that user is editing this project. I also want to add the file type XAML to "Add New Item" window so that it will add a new xaml file to the project which has the following code

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >

</Window>
Was it helpful?

Solution

Found a Solution :) Ensure to have .Net Framework 3.0 or above installed. ( don't need to have C# compilers installed. )

  1. Create your C++ project. ( I guess this could work with other project types too )
  2. Add a new item the way you normally do ( there are many ways, so just use the way you like ) and that item should be a text file with the extention .xaml ( e.g. "myFile.xaml" )
  3. Open it in the Visual Studio (See that design area is available but its giving an error)
  4. Ignore the messages/warnings/errors for a second and Add the following code to your xaml file,

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >

</Window>

  1. Close the file and open it again. Goto the design area of the xaml file and see that it is now having the GUI editor capabilities.

p.s.
Just in case you are not familiar with WPF, remember to add a Grid tag inside this window tag. Otherwise you cannot add any rectangles or other things and edit them correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top