MenuAdv


Display a Window containing a MenuAdv and respond to the user clicking on it



XAML


∇  xaml←MenuAdvXAML
⍝ XAML for the MenuAdv example
 xaml←⊂'<Window'
 xaml,←⊂'   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"'
 xaml,←⊂'   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"'
 xaml,←⊂'   xmlns:sftools="clr-namespace:Syncfusion.Windows.Shared;assembly=Syncfusion.Shared.WPF"'
 xaml,←⊂'   Height="100" Width="300" > '
 xaml,←⊂'   <Grid>'
 xaml,←⊂'       <sftools:MenuAdv>'
 xaml,←⊂'         <sftools:MenuItemAdv Header="Fish" Name="mniFish"/>'
 xaml,←⊂'         <sftools:MenuItemAdv Header="Meat">'
 xaml,←⊂'           <sftools:MenuItemAdv Header="Beef" Name="mniBeef"/>'
 xaml,←⊂'           <sftools:MenuItemAdv Header="Pork" Name="mniPork"/>'
 xaml,←⊂'         </sftools:MenuItemAdv>'
 xaml,←⊂'       </sftools:MenuAdv>'
 xaml,←⊂'   </Grid>'
 xaml,←⊂'</Window>'


Code


∇ MenuAdv;⎕IO;⎕ML
⍝ Simple MenuAdv example
 ⎕IO ⎕ML←0 3
 xaml←MenuAdvXAML
 #.window←#.UTIL.WPF.LoadXaml xaml(⊂'SyncTools')
 window_mnifish window_mnibeef window_mnipork←{#.window.FindName⊂⍵}¨'mniFish' 'mniBeef' 'mniPork'
 (window_mnifish window_mnibeef window_mnipork).onClick←⊂'#.MenuAdv.Pick'
 {}#.window.ShowDialog


∇ Pick w;⎕IO;⎕ML
⍝ Callabck for a MenuAdv control
 ⎕IO ⎕ML←0 3
 ⎕←'You clicked on <',((↑w).Name),'>'


The 'SyncTools' argument to #.UTIL.LoadXAML has the effect of adding

'Syncfusion.Windows.Shared,Syncfusion/4.5/Syncfusion.Shared.WPF.dll'
'SyncFusion.Windows.Tools.Controls,Syncfusion/4.5/Syncfusion.Tools.WPF.dll

 to the ⎕USING list of
LoadXAML

Notice that everything within a MenuAdv seems to have to be a MenuItemAdv, with nesting (the <Meat> submenu) arising by nesting the definitions - which differs (if I recall correctly) the Dyalog Native approach of menus within menus (menuitem appearing only at the end of the chain).

Operation


      #.MenuAdv.MenuAdv  
You clicked on <mniBeef>
You clicked on <mniPork>
You clicked on <mniFish>

Unresolved Issues


Nothing springing to mind at the moment - pending some use of this within applications.