XAML issue – Creating a function

Welcome Forums General PowerShell Q&A XAML issue – Creating a function

Viewing 2 reply threads
  • Author
    Posts
    • #265121
      Participant
      Topics: 2
      Replies: 5
      Points: 61
      Rank: Member

      Hi All,

      I’m trying to tidy up my code and one part is to create a function or module for my runspace creation to reduce repetition of code.

      If I attempt to import the XAML and related code into the function, the code executes, but no GUI.

      If I past the XAML and related code into the function it all works normally

      I know there are issues with adding a script and XAML, but there must be a workaround to this?

      Thanks

      James

    • #265127
      Participant
      Topics: 2
      Replies: 5
      Points: 61
      Rank: Member

      So if I replace line 59 with the contents of $code at line 78, it all works swimmingly, but that reduces the effectiveness of the function

      I can save the contents of $code at line 78 into a script .ps1 file and import it at line 59 and that works fine too

      It’s only if I create a subscript of that code and then try and import it to the function that it doesn’t work

       

      thanks

      James

    • #265130
      Participant
      Topics: 2
      Replies: 5
      Points: 61
      Rank: Member

      here’s the guiStyle.ps1 script contents if you need to run my code above

Viewing 2 reply threads
  • You must be logged in to reply to this topic.