473,785 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using CodeDom to create XAML windows

will CodeDom create XAML windows or just regular windows forms?

If so, how to I tell it to create a xaml window instead of a windows form?

thanks

--
mo*******@noema il.noemail
Mar 26 '07 #1
6 5769
moondaddy <mo*******@noem ail.noemailwrot e:
will CodeDom create XAML windows or just regular windows forms?

If so, how to I tell it to create a xaml window instead of a windows form?
Just change which type it's creating - can you give us a sample of your
current CodeDom code?

There's no such thing as a XAML window really - just the new WPF
classes, which often happen to be loaded using XAML.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 26 '07 #2
I don't have any codedom code yet. I'm just trying to figure out where to
start. I rolled my own code-gen tool which writes the data access and
business classes, and now I'm attacking the UI tier and wanted to use WPF
windows. I found a codedom sample at:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio .v80.en/dv_fxsamples/local/sampleexecutabl es/Applications/CodeDOMSample.z ip

which seemed to be way more complicated than it should be. If I cant find
any clean samples using codedom to create WPF classes, then I will probable
add the initial class via VS to the project (someWindow.xam l) and generate
the xaml and cs code behind with my tool and just paste it in.

Actually, all I need to do is create 'someWindow.xam l' via codedom so that
all the hidden classes are created for me, then my tool can overwrite the
someWindow.xaml and someWindow.cs files with my custom code.
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
moondaddy <mo*******@noem ail.noemailwrot e:
>will CodeDom create XAML windows or just regular windows forms?

If so, how to I tell it to create a xaml window instead of a windows
form?

Just change which type it's creating - can you give us a sample of your
current CodeDom code?

There's no such thing as a XAML window really - just the new WPF
classes, which often happen to be loaded using XAML.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 26 '07 #3
OK here's my sample code. I dont see where or how to change the type to a
xaml window object.
static void Main(string[] args)
{

CodeCompileUnit compileUnit = new CodeCompileUnit ();
CodeNamespace ns = new CodeNamespace(" WarpCode");
compileUnit.Nam espaces.Add(ns) ;
GenerateCSharpC ode(compileUnit );
}

public static String GenerateCSharpC ode(CodeCompile Unit compileunit)
{
// Generate the code with the C# code provider.
CSharpCodeProvi der provider = new CSharpCodeProvi der();

// Build the output file name.
string path =
@"D:\nwis\Apps\ ConsoleApplicat ion3\ConsoleApp lication3\tmpCo de\";
String sourceFile;
if (provider.FileE xtension[0] == '.')
{
sourceFile = "HelloWorld " + provider.FileEx tension;
}
else
{
sourceFile = "HelloWorld ." + provider.FileEx tension;
}

provider.GetTyp eOutput

// Create a TextWriter to a StreamWriter to the output file.
IndentedTextWri ter tw = new IndentedTextWri ter(
new StreamWriter(pa th + sourceFile, false), " ");

// Generate source code using the code provider.
provider.Genera teCodeFromCompi leUnit(compileu nit, tw,
new CodeGeneratorOp tions());

// Close the output file.
tw.Close();

return sourceFile;
}


"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
moondaddy <mo*******@noem ail.noemailwrot e:
>will CodeDom create XAML windows or just regular windows forms?

If so, how to I tell it to create a xaml window instead of a windows
form?

Just change which type it's creating - can you give us a sample of your
current CodeDom code?

There's no such thing as a XAML window really - just the new WPF
classes, which often happen to be loaded using XAML.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 26 '07 #4
moondaddy <mo*******@noem ail.noemailwrot e:
OK here's my sample code. I dont see where or how to change the type to a
xaml window object.
Again, there's no such thing as a "xaml window object". If your sample
code compiled and produced a WinForms application, it would be easier
to show the equivalent using a WPF window - but as it is, there's
nothing significant in there to change.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 26 '07 #5
Hi,

Code Document Object Model(CodeDOM) enables developers of programs that
emit source code to generate source code in multiple programming languages
at run time, based on a single model that represents the code to render.

We could use CodeDOM to generate the source code behind the UI tier, as you
have done. But as for a WPF window, since it is made up of XML without any
source code, we should not generate its content using CodeDOM. To geneate
an XML file, we could use System.Xml.XMLW riter class.

Note that you should save the XML file as *. xaml.

For more information on how to create XML writers, you may visit the
following link.

'Creating XML Writers'
http://msdn2.microsoft.com/en-us/library/kkz7cs0d.aspx

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 27 '07 #6
Thanks. thats what i needed to know.

"Linda Liu [MSFT]" <v-****@online.mic rosoft.comwrote in message
news:b6******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi,

Code Document Object Model(CodeDOM) enables developers of programs that
emit source code to generate source code in multiple programming languages
at run time, based on a single model that represents the code to render.

We could use CodeDOM to generate the source code behind the UI tier, as
you
have done. But as for a WPF window, since it is made up of XML without any
source code, we should not generate its content using CodeDOM. To geneate
an XML file, we could use System.Xml.XMLW riter class.

Note that you should save the XML file as *. xaml.

For more information on how to create XML writers, you may visit the
following link.

'Creating XML Writers'
http://msdn2.microsoft.com/en-us/library/kkz7cs0d.aspx

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Mar 27 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2362
by: Guillaume | last post by:
I don't think I'm the only one with this challenge so… I made code with the CodeDom classes and made code to create a new solution and a new project Now I want to get the codedom code in the new created IDE instance How can do that? Is there a way to paste the string (CodeDom output) into a class? Out is the a way to insert the created CodeDom instance into the IDE I've seen something like the CodeModel which looks like a different...
2
2889
by: KK | last post by:
Hi All I need to create a windows form control(from System.Windows.Forms.dll assembly) dynamically using Activator.How do I achieve this?Sample code is much more helpful. Thanks in advance Regards Krishna
7
10001
by: Clint Herron | last post by:
Howdy! I posted this question on CSharpCorner.com, but then realized I should probably post it on a more active newsgroup. This will be my only cross-post. I'm creating a game engine, and using CodeDOM for my scripting needs (I realize I could use yacc or something else, but I wanted to try using CodeDOM -- this is more of an exercise for me to learn this stuff). Well, I compile my in-game scripts just fine. See appendix A for my code
0
2862
by: Marco Viana | last post by:
Hi, I'm developing an ASP.NET application with Visual Studio .NET 2003 in a Win XP Professional, .NET Framework 1.1 and IIS 5.1 computer with all the lattest patches. When testing a page sometimes i get the following error. Does anyone knows what i have to do to get rid of this error?
7
2165
by: GVN | last post by:
Hi All, I would like to write a .NET application which uses XAML. The following is my system's specification: Operating System : Windows XP ..NET Framework : 1.1
1
4896
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I may have painted myself into a corner with GenerateInMemory=true. My app need a custom user step. Users want to code (sort of - they are not programmers) some refinements to a search procedure. They can concoct a moderately complex boolean expression, and that suffices. I will take their statements, add top and bottom text, and now I can do a CodeDom compile. I generate an assembly via CodeDom with GenerateInMemory. I make a...
3
2503
by: arunonw3 | last post by:
Please answer me 1. Is XAML maily aiming windows. Why is the controls on double click not produce the event handlers in the c# file( code behind or something ...) 2. XAML web browser applications doesnt need IIS? Then can we use it for server side programming? If yes how is it working? 3.How to use the asp.net objects from xaml (web) page. Or is there any
6
10114
by: star-italia | last post by:
Hi, Is it possible to include a XAML file into another XAML file? For example If i have - Window1.xaml - Window2.xaml and both have a treeview with a custom Style, can i describe the style in a trvStyle.xaml and then include it in both windows? Thanks in advance
8
11522
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml file. each control has a border with another style, and each border has a unique path inside of it. I need to dynamically add these content controls using c# at runtime and am having trouble referencing the styles and adding the path into the...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.