Click here to Skip to main content
15,892,005 members
Articles / Desktop Programming / XAML

Silverlight 1.0 Full JavaScript Intellisense

Rate me:
Please Sign up or sign in to vote.
3.81/5 (16 votes)
21 Dec 2007Ms-PL11 min read 31.9K   141   17  
An article about Silverlight 1.0 full JavaScript Intellisense
<html dir="ltr" xmlns:mshelp="http://msdn.microsoft.com/mshelp"
xmlns:silverlightsdk="http://msdn.microsoft.com/silverlight" xmlns=
"http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="online documentation, web online help, web help, chm2web" />
<meta http-equiv="Content-Style-Type" content="text/css" />

<meta name="generator" content="chm2web Standard 2.7 (unicode)" />
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
<title>Remove Method</title>
<link rel="stylesheet" href="../../default.css" type="text/css" />

<script type="text/JavaScript" src="../../files/supply.js"></script>
<script type="text/JavaScript">
chmtop.c2wtopf.pageid = "reference/m_collection_remove.htm";
</script>

</head>
<body topmargin="0"><script type="text/JavaScript"> 
if (window.name != "content") 
  document.write(" <table width=\"100%\" bgcolor=\"#e1e1e1\"cellspacing=\"2\" cellpadding=\"0\" style=\"border-collapse: collapse; font-family: sans-serif; font-size: 14px; color: #000000; text-decoration: none;  \"> <tr> <td align=\"center\" style=\"border-bottom: 2px solid gray\" > <br>&nbsp;Click <a href=\"../../index.html?page=source%2freference%2fm_collection_remove.htm\">here</a> to show toolbars of the Web Online Help System: <a href=\"../../index.html?page=source%2freference%2fm_collection_remove.htm\">show toolbars</a><br>&nbsp;</td></tr></table><br> "); 
</script>
<!-- !chm2web! -->

<span id="sdkbannersection"></span>
<div class="tableSection"><span id="sdkbannersection"></span>
<table class="buttonbarshade" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
</table>
</div>

<div class="tableSection"><span id="sdkbannersection"></span>
<table class="buttonbartable" cellspacing="0">
<tr id="hdr">
<td class="runninghead" nowrap="nowrap"><img src=
"../common/logo.png" height="21" alt="Silverlight SDK" />
</td>
</tr>
</table>
</div>

<p><span class="betaboilerplate"><font color="gray" pointsize="8.5"
face="Verdana">[This topic is pre-release documentation and is
subject to change in future releases. Blank topics are included as
placeholders.]</font></span>
</p>

<h1><a name="silverlight_collection_remove_method"></a>Remove
Method</h1>

<div id="mainSection">
<div id="mainBody">
<p>Removes the specified object from the collection.</p>

<div id="syntaxblock">
<table class="auto_syntaxtable" id="syntaxtable" style=
"width: 90%; background: #CCCCCC; border: none;">
<tr id="xamlSyntaxBlock">
<th class="syntaxblocklanguage" nowrap="nowrap" style=
"width: 150px; background: #EEEEEE; vertical-align: top;">XAML</th>
<td class="syntaxblockcode" style="background:white;">
<div class="codesyntax">You cannot use methods in XAML.</div>
</td>
</tr>

<tr id="scriptingSyntaxBlock">
<th class="syntaxblocklanguage" nowrap="nowrap" style=
"width: 150px; background: #EEEEEE; vertical-align: top;">
Scripting</th>
<td class="syntaxblockcode" style="background:white;">
<div class="codesyntax" style=
"font-family: 'Courier New', Courier, monospace;">
<i>object</i>.remove(<b>value</b>)</div>
</td>
</tr>
</table>
</div>

<div id="parametersection">
<h4>Parameters</h4>

<div class="tableSection">
<table class="parametertable">
<tr>
<td class="parametername"><i>value</i>
</td>
<td class="parameterdesc"><b>Object</b>
<p>The object to remove from the collection.</p>
</td>
</tr>
</table>
</div>
</div>

<div id="returnvaluesection">
<h4>Return Value</h4>

<p><a href="o_boolean.htm">Boolean</a>
</p>

<p><b>true</b> if value was removed from the collection; otherwise,
<b>false</b>.</p>
</div>

<h4>Remarks</h4>

<p>The <b>Remove</b> method allows you to remove a child object
from the parent's collection by referencing the object's
<b>x:Name</b> attribute value. As soon as objects are removed from
the Silverlight object hierarchy, they are no longer rendered. When
you remove an object using the <b>Remove</b> or <b>RemoveAt</b>
methods, you are disconnecting the object from the Silverlight
object hierarchy. The disconnected object is now a XAML fragment
that can be connected back to the object hierarchy using the
<a href="m_collection_add.htm">Add</a> method. The following two
diagrams illustrate the process of disconnecting objects from the
Silverlight object hierarchy:</p>

<p><img alt=
"Removing objects from the Silverlight object hierarchy" src=
"../conceptual/images/visualtree_04.png" width="234" height=
"176" /><br />
<b>Removing an object from the Silverlight object hierachy</b>
</p>
<br />

<p><img alt=
"Disconnected XAML fragment and Silverlight object hierarchy" src=
"../conceptual/images/visualtree_01.png" width="234" height=
"176" /><br />
<b>Disconnected XAML fragment and Silverlight object hierarchy</b>
</p>

<p>The following JavaScript example shows to remove a
<b>TextBlock</b> from its parent <b>Canvas</b> object by using the
<b>Remove</b> method on the object's collection of children.</p>

<div class="snippetdistributor_codesnippet" id=
"referencing_objects_snip#RemoveObject">
<div style="width: 99%;">
<table class="codeexampletable" style=
"border: 1px solid #999999; background: #CCCCCC; width: 99%;">
<tr>
<th class="codelanguagecell" style=
"background: #CCCCCC; text-align: left;">JavaScript</th>
</tr>

<tr>
<td class="codeblockcell" style=
"background: #e6e6e6; border: none;">
<pre class="codeblock" style=
"background: transparent; border: none; margin: 0px; padding: 0px; font-family:'Courier New', Courier, monospace;">

function removeCaption(rootCanvas)
{
    // Retrieve the TextBlock object.
    var captionTextBlock = rootCanvas.findName("myCaption");

    if (captionTextBlock != null)
    {
        rootCanvas.children.remove(captionTextBlock);
    }
}
</pre>
</td>
</tr>
</table>
</div>
</div>

<p>The <a href="m_collection_removeat.htm">RemoveAt</a> method
allows you to remove a child object at a specified index value in
the parent's collection. This means the child object does not
require an <b>x:Name</b> attribute value. The following JavaScript
example shows to remove the first object from a parent
<b>Canvas</b> object by using the <b>RemoveAt</b> method:</p>

<div class="snippetdistributor_codesnippet" id=
"referencing_objects_snip#RemoveAtObject">
<div style="width: 99%;">
<table class="codeexampletable" style=
"border: 1px solid #999999; background: #CCCCCC; width: 99%;">
<tr>
<th class="codelanguagecell" style=
"background: #CCCCCC; text-align: left;">JavaScript</th>
</tr>

<tr>
<td class="codeblockcell" style=
"background: #e6e6e6; border: none;">
<pre class="codeblock" style=
"background: transparent; border: none; margin: 0px; padding: 0px; font-family:'Courier New', Courier, monospace;">

// Remove the first child object from the parent collection.
myCanvas.children.removeAt(0);
</pre>
</td>
</tr>
</table>
</div>
</div>

<p>You can remove all objects in a collection by using the <a href=
"m_collection_clear.htm">Clear</a> method, which is equivalent to
using the <a href="m_collection_removeat.htm">RemoveAt</a> method
for each item in the collection. The following JavaScript example
shows to removes all items from a collection using the <b>Clear</b>
method.</p>

<div class="snippetdistributor_codesnippet" id=
"referencing_objects_snip#ClearObjects">
<div style="width: 99%;">
<table class="codeexampletable" style=
"border: 1px solid #999999; background: #CCCCCC; width: 99%;">
<tr>
<th class="codelanguagecell" style=
"background: #CCCCCC; text-align: left;">JavaScript</th>
</tr>

<tr>
<td class="codeblockcell" style=
"background: #e6e6e6; border: none;">
<pre class="codeblock" style=
"background: transparent; border: none; margin: 0px; padding: 0px; font-family:'Courier New', Courier, monospace;">

// Remove all child objects from the parent collection.
myCanvas.children.clear();
</pre>
</td>
</tr>
</table>
</div>
</div>

<h4>Applies To</h4>

<p><a href=
"o_colorkeyframecollection.htm">ColorKeyFrameCollection</a>,
<a href=
"o_doublekeyframecollection.htm">DoubleKeyFrameCollection</a>,
<a href="o_gradientstopcollection.htm">GradientStopCollection</a>,
<a href="o_pathfigurecollection.htm">PathFigureCollection</a>,
<a href="o_pathsegmentcollection.htm">PathSegmentCollection</a>,
<a href=
"o_pointkeyframecollection.htm">PointKeyFrameCollection</a>,
<a href="o_strokecollection.htm">StrokeCollection</a>, <a href=
"o_styluspointcollection.htm">StylusPointCollection</a>, <a href=
"o_triggeractioncollection.htm">TriggerActionCollection</a>,
<a href="o_triggercollection.htm">TriggerCollection</a>, <a href=
"o_uielementcollection.htm">UIElementCollection</a></p>

<h4>See Also</h4>

<p><a href="m_collection_clear.htm">Clear</a>, <a href=
"m_collection_removeat.htm">RemoveAt</a>, <a href=
"../conceptual/referencing_objects.htm">Referencing and Modifying
Silverlight Objects</a></p>
</div>
</div>

<script type="text/JavaScript">
var fe = FindFrame("toc", top);
if ((fe != null) && (chmtop.c2wtopf.jstree != null)) {
  if (chmtop.c2wtopf.FITEMS[chmtop.c2wtopf.pagenum] != chmtop.c2wtopf.pageid)
    chmtop.c2wtopf.jstree.OpenTreeNode("source/" + chmtop.c2wtopf.pageid);
}
</script>

<!-- CHM2WEB -->
<!-- DO NOT DELETE OR MODIFY THIS CODE WITHOUT 
     WRITTEN PERMISSION OF A!K RESEARCH LABS -->
<table width="100%" cellspacing="0" cellpadding="0" 
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color:white; border-top: 1px solid gray;"> 
<a href="http://chm2web.aklabs.com" target="_blank" style="font-family: sans-serif;  font-size: 11px; text-decoration: none;"><font color="gray">Converted from CHM to HTML with <b>chm2web Standard 2.7 (unicode)</b></font></a>
</td></tr></table> 
<!-- /CHM2WEB -->

</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
JustinAngel.Net, Senior .Net consultant
Israel Israel
Justin-Josef Angel is a C# Microsoft Most Valuable professional, a Senior .Net consultant in Israel with 4 years of .Net experience and has 8 years of Web experience.

Justin's been working this past year on two Enterprise sized Silverlight projects with his customers. During that time he's gained a real-insight into Silverlight's inner workings and how to integrate Silverlight into the real world of software development. Additionally, During that time he's developed a few well-known projects like the "Silverlight 1.0 Javascript Intellisense", "Silverlight 1.1 Hebrew & Arabic Languages support" and a few others you might know.

Justin is also a seasoned presenter with an impressive track-record of talking in front of thousands of people in Israel.

Justin owns the first .Net blog written in Hebrew - http://www.JustinAngel.Net .
And he also owns an additional blog with mixed Hebrew & English content - http://blogs.Microsoft.co.il/blogs/JustinAngel.

A full list of his articles (all 100+ of them) can be found at: http://www.JustinAngel.Net/#index




Comments and Discussions