locked
JavaScript RRS feed

  • Question

  • Do you use JavaScript to add functionality in SkecthFlow?

    Thanks
    Friday, March 5, 2010 5:09 PM

Answers

  • Here is an example of how you could do this in xaml and c# in a Silverlight project.

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    namespace SilverlightApplication15
    {
    	public partial class MainPage : UserControl
    	{
    		public MainPage()
    		{
    			// Required to initialize variables
    			InitializeComponent();
    		}
    
    		private void CB2Click(object sender, System.Windows.RoutedEventArgs e)
    		{
    			if(this.CB2.IsChecked == true)
    			{
    				this.CB1.IsChecked = true;
    			}
    			else
    			{
    				this.CB1.IsChecked = false;
    			}
    		}
    
    		private void CB3Click(object sender, System.Windows.RoutedEventArgs e)
    		{
    			if(this.CB3.IsChecked == true)
    			{
    				this.CB2.IsChecked = true;
    				this.CB1.IsChecked = true;
    			}
    			else
    			{
    				this.CB2.IsChecked = false;
    				this.CB1.IsChecked = false;
    			}
    		}
    	}
    }

    <UserControl
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	x:Class="SilverlightApplication15.MainPage"
    	Width="640" Height="480">
    
    	<Grid x:Name="LayoutRoot" Background="White">
    		<CheckBox x:Name="CB1" Content="CheckBox"/>
    		<CheckBox x:Name="CB2" Content="CheckBox" Click="CB2Click"/>
    		<CheckBox x:Name="CB3" Content="CheckBox" Click="CB3Click"/>
    	</Grid>
    </UserControl>
    • Proposed as answer by Chuck HaysModerator Friday, March 5, 2010 10:27 PM
    • Marked as answer by jh08tt Monday, March 8, 2010 1:13 PM
    Friday, March 5, 2010 10:27 PM
    Moderator

All replies

  • Not sure if this was meant as a "Does anyone do this?" question, but in general, no.  What are you trying to do that might require javascript?

    Friday, March 5, 2010 5:24 PM
    Moderator
  • I want my checkboxes to be a little more dynamic. This is the code currently in HTML.

    <html>
    <head>
    <script type="text/javascript">
    
    
    function checkit2(){
    
    	var myBoo = document.getElementById("2").checked;	
    	if(myBoo){
    		document.getElementById("1").checked=true;	
    	}
    
    	else{
    		document.getElementById("1").checked=false;	
    	}
    }
    
    function checkit3(){
    
    	var myBoo = document.getElementById("3").checked;
    	if(myBoo){
    		document.getElementById("1").checked=true;
    		document.getElementById("2").checked=true;
    	}
    
    	else{
    		document.getElementById("1").checked=false;
    		document.getElementById("2").checked=false;
    	}
    }
    
    </script>
    </head>
    
    
    <body>
    <form>
    	<input type="checkbox" id="1" /> 1 </br>
    	<input type="checkbox" onclick="checkit2()" id="2" /> 2 </br> 
    	<input type="checkbox" onclick="checkit3()" id="3" /> 3 </br> 
    </form>
    </body>
    
    </html>
    Friday, March 5, 2010 6:09 PM
  • Here is an example of how you could do this in xaml and c# in a Silverlight project.

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    namespace SilverlightApplication15
    {
    	public partial class MainPage : UserControl
    	{
    		public MainPage()
    		{
    			// Required to initialize variables
    			InitializeComponent();
    		}
    
    		private void CB2Click(object sender, System.Windows.RoutedEventArgs e)
    		{
    			if(this.CB2.IsChecked == true)
    			{
    				this.CB1.IsChecked = true;
    			}
    			else
    			{
    				this.CB1.IsChecked = false;
    			}
    		}
    
    		private void CB3Click(object sender, System.Windows.RoutedEventArgs e)
    		{
    			if(this.CB3.IsChecked == true)
    			{
    				this.CB2.IsChecked = true;
    				this.CB1.IsChecked = true;
    			}
    			else
    			{
    				this.CB2.IsChecked = false;
    				this.CB1.IsChecked = false;
    			}
    		}
    	}
    }

    <UserControl
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	x:Class="SilverlightApplication15.MainPage"
    	Width="640" Height="480">
    
    	<Grid x:Name="LayoutRoot" Background="White">
    		<CheckBox x:Name="CB1" Content="CheckBox"/>
    		<CheckBox x:Name="CB2" Content="CheckBox" Click="CB2Click"/>
    		<CheckBox x:Name="CB3" Content="CheckBox" Click="CB3Click"/>
    	</Grid>
    </UserControl>
    • Proposed as answer by Chuck HaysModerator Friday, March 5, 2010 10:27 PM
    • Marked as answer by jh08tt Monday, March 8, 2010 1:13 PM
    Friday, March 5, 2010 10:27 PM
    Moderator
  • Thank you!
    Monday, March 8, 2010 1:13 PM