XAML - 1 and Done

Started by stanl, January 03, 2021, 05:52:18 AM

Previous topic - Next topic

stanl

Attached is a simple XAML file to support the script below. Based on a discussion of XAML that re-focused Jim's Rich Text Control thread I want to clear up the main issue with XAML - WB.

       
  • You can easily create XAML files in VS - just create a WPF form, insert controls and it writes the xaml for you.
  • With a few lines removed from the VS code the form/Window can be activated with WB CLR code.
  • But that is about as far as you can go.
Running the script with the attached file will bring up a window with a series of buttons. There is also a lame effort to itemize the Buttons as I need more practice with XPath as it has been years since I have played with it :o .


The ask would be: is there a way to process a click event on any of the buttons?
Code (WINBATCH) Select


;CLR  - test XAML Buttons
cXAML = dirscript():"testbutton.xaml"
If ! FileExist(cXAML) Then Terminate(@TRUE,"XAML File Not Found",cXAML)
XAML = FileGet(cXAML)
Message("",XAML)
_True = ObjectType('BOOL',1)
_False = ObjectType('BOOL',0)
ObjectClrOption('useany','System')
ObjectCLrOPtion('useany','PresentationFramework')
ObjectCLrOPtion('useany','PresentationCore')
ObjectClrOption('useany','System.Xml')
oDOc =  ObjectClrNew('System.Xml.XmlDocument')
oDoc.LoadXml(XAML)
oXML = ObjectClrNew('System.Xml.XmlNodeReader',oDoc)


;create list pair to identify Buttons
;====================================================================================================
blist =""
elements = oDoc.GetElementsByTagName("Button")
n = elements.Count
For i = 0 To n-1
   n1 = elements.Item(i).Attributes.Count
   att = ""
   For j=0 To n1-1
      att = att:elements.Item(i).Attributes.Item(j).Name:"="
      att = att:elements.Item(i).Attributes.Item(j).Value:","
   Next
   blist = blist:strsub(att,1,strlen(att)-1):@LF
Next
Message("XAML Buttons",blist)
;====================================================================================================


;Load Xaml
oXamlReader = ObjectClrNew('System.Windows.Markup.XamlReader')
oWin = oXamlReader.Load(oXML)
oWin = ObjectClrType( 'System.Windows.Window', oWin )
;Display Window for 5 seconds then close
;otherwise oWin.ShowDialog() will keep Window Open
oWin.Show()
TimeDelay(5)
oWin.Close()


Exit
;====================================================================================================



td

As has been mentioned multiple times before and as far as I know, the answer to your question is "No". At least, that is the case without writing and compiling some C# or other MSFT extended language.  The technical explanation for this goes beyond the scope of this forum.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl


td

Thanks for taking the time to write a script that demonstrates creating a UI with MSFT's dotNet support for AXML.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Just as a side note. I create a GUI with WinForms and compile with PS. Attached is not much. 4 buttons, click first 3 they change colors, last one exists, but I can access the click event. Now, to execute any of the fist 3 clicks in WB code would take minutes, in PS a lot longer as there is so much extra stuff I could easily do with WB. Kinda want the best of both worlds....


Attached may throw an initial warning as it an exe.

td

MSFT is starting to push their "Fluent Design" UI. How much is marketing and how much is actual changes to the basic set of Windows widgets that have become familiar to Windows users over the years will help determine the direction of WIL/WinBath's  scriptable UI.  The coming fall release of Windows 10 update may help clarify their direction and the direction of WinBatch.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on January 05, 2021, 10:20:10 AM
  The coming fall release of Windows 10 update may help clarify their direction and the direction of WinBatch.


at which point you can sign me up :)