using CodeDom to create XAML windows

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • moondaddy

    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

    --
    moondaddy@noema il.noemail


  • Jon Skeet [C# MVP]

    #2
    Re: using CodeDom to create XAML windows

    moondaddy <moondaddy@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 - <skeet@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

    Comment

    • moondaddy

      #3
      Re: using CodeDom to create XAML windows

      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]" <skeet@pobox.co mwrote in message
      news:MPG.20722f 71f625e3d598da2 8@msnews.micros oft.com...
      moondaddy <moondaddy@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 - <skeet@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

      Comment

      • moondaddy

        #4
        Re: using CodeDom to create XAML windows

        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]" <skeet@pobox.co mwrote in message
        news:MPG.20722f 71f625e3d598da2 8@msnews.micros oft.com...
        moondaddy <moondaddy@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 - <skeet@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

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: using CodeDom to create XAML windows

          moondaddy <moondaddy@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 - <skeet@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

          Comment

          • Linda Liu [MSFT]

            #6
            Re: using CodeDom to create XAML windows

            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'


            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
            Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.

            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.

            Comment

            • moondaddy

              #7
              Re: using CodeDom to create XAML windows

              Thanks. thats what i needed to know.

              "Linda Liu [MSFT]" <v-lliu@online.mic rosoft.comwrote in message
              news:b6Hk2QDcHH A.2256@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'

              >
              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
              Learn with interactive lessons and technical documentation, earn professional development hours and certifications, and connect with the community.

              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.
              >

              Comment

              Working...