Rating


Allow the user to choose a rating by clicking on a row of stars



XAML


∇  xaml←RatingXAML
⍝ XAML for the Rating 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.Controls.Input;assembly=SyncFusion.SfInput.Wpf"'
 xaml,←⊂'    SizeToContent="WidthAndHeight" >'
 xaml,←⊂'    <StackPanel>'
 xaml,←⊂'        <Label Content="Give a rating to Syncfusion"/>'
 xaml,←⊂'        <sftools:SfRating Name="ranting"/>'
 xaml,←⊂'    </StackPanel>'
 xaml,←⊂'</Window>'


Code


∇  z←Rating(items value);⎕IO;⎕ML;xaml;⎕USING;_app
⍝ Simple Rating example
 ⎕IO ⎕ML←0 3
 xaml←RatingXAML
 #.window←#.UTIL.WPF.LoadXaml xaml(⊂'SyncTools')
 window_ranting←#.window.FindName⊂'ranting'
 window_ranting.(ItemsCount Value)←items value
 ⎕USING,←⊂'System.Windows,WPF\PresentationFramework.dll' 
 _app←⎕NEW Application
 _app.ShutdownMode←ShutdownMode.OnExplicitShutdown
 _app.MainWindow←#.window
 {}#.window.ShowDialog
 z←window_ranting.Value 



No pretence here to understand what's going on with the <Application> stuff - the hint in SyncFusion's documentation is that they show their XAML with <Rating> included in <Page> tags rather than <Window>.  I am indebted to John Daintree for showing the code needed to make this example work.  Be alert that if doing repeated experiments/tests that the <CloseAppDomain> command must be used between repeats.

Unfortunately, it appears impossible to give a zero rating.

The 'SyncTools' argument to #.UTIL.LoadXAML has the effect of adding
  Syncfusion.Windows.Shared,Syncfusion/4.5/Syncfusion.Shared.WPF.dll
 Syncfusion.Tools.WPF,Syncfusion/4.5/Syncfusion.Tools.WPF.dll      
 Syncfusion.SfInput.WPF,Syncfusion/4.5/Syncfusion.SfInput.WPF.dll  

 to the ⎕USING list of LoadXAML

Operation


       #.Rating.Rating 10 1
2

Unresolved Issues