Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Window1.xaml -> Window1.xaml.cs - how do I get this hierarchially ordered

Window1.xaml -> Window1.xaml.cs - how do I get this hierarchially ordered

Scheduled Pinned Locked Moved .NET (Core and Framework)
wpfquestioncsharpdata-structuresxml
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krischu
    wrote on last edited by
    #1

    When I create open WPF program examples I see Window1.xaml and a Window1.xaml.cs file neatly grouped together, the .cs files having a link arrow showing the relation or depency between the two files. But when I add a xaml file, paste some xml (xaml) into it from another project, I have to create a separate class file Window1.xaml.cs for example. This file, when added as a new item, is in the same tree hierarchy than the .xaml file and is not showing this arrow icon. Am I doing something wrong? -- Christoph

    A S 2 Replies Last reply
    0
    • K Krischu

      When I create open WPF program examples I see Window1.xaml and a Window1.xaml.cs file neatly grouped together, the .cs files having a link arrow showing the relation or depency between the two files. But when I add a xaml file, paste some xml (xaml) into it from another project, I have to create a separate class file Window1.xaml.cs for example. This file, when added as a new item, is in the same tree hierarchy than the .xaml file and is not showing this arrow icon. Am I doing something wrong? -- Christoph

      A Offline
      A Offline
      Abhinav S
      wrote on last edited by
      #2

      Make sure they share the same namespaces.....if they do, try reopening your solution again and they should be within the same tree hierarchy.

      My signature "sucks" today

      1 Reply Last reply
      0
      • K Krischu

        When I create open WPF program examples I see Window1.xaml and a Window1.xaml.cs file neatly grouped together, the .cs files having a link arrow showing the relation or depency between the two files. But when I add a xaml file, paste some xml (xaml) into it from another project, I have to create a separate class file Window1.xaml.cs for example. This file, when added as a new item, is in the same tree hierarchy than the .xaml file and is not showing this arrow icon. Am I doing something wrong? -- Christoph

        S Offline
        S Offline
        Simon P Stevens
        wrote on last edited by
        #3

        In visual studio if you right click on your project and select "Add"->"New Item" and then select a WPF window, or user control visual studio will automatically add both the xaml and the xaml.cs files which you can paste your code into. However, if this doesn't suit you, or they somehow become disconnected - which does seem to happen sometimes - you can reattach them like this: 1) Right click on the project and select "Unload project" 2) Now your project is unloaded, right click again and select "Edit [projectname].csproj". 3) This will open the the project file for editing manually, it's just a regular xml file so is fairly easy to read. 4) Search within the xml of the csproj file for the name of your unlinked files. 5) To link a .xaml file with it's child .xaml.cs file it should look something like this:

        <Page Include="Window1.xaml">
          <SubType>Designer</SubType>
          <Generator>MSBuild:Compile</Generator>
        </Page>
        
        <Compile Include="Window1.xaml.cs">
          <DependentUpon>Window1.xaml</DependentUpon>
        </Compile>
        

        (You may find that the two files are not next to each other in the .csproj file.) If they are not correctly linked, you may find that the .xaml.cs reference is missing the dependant tag. If you just added them as regular files, you may also find the tags aren't quite correct. 6) You just need to edit you file to match this layout. 7) Now save the .csproj file. Right click on the project and select "Reload project". You two files should now be linked.

        Simon

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups