* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
1.7 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
|---|---|---|---|---|---|---|---|---|---|
| How to: Define a Name Scope | 03/30/2017 |
|
|
4f361925-6a08-40dc-8231-a61111c6b28b |
How to: Define a Name Scope
To animate with xref:System.Windows.Media.Animation.Storyboard in code, you must create a xref:System.Windows.NameScope and register the target objects' names with the element that owns that name scope. In the following example, a xref:System.Windows.NameScope is created for myMainPanel. Two buttons, button1 and button2, are added to the panel, and their names registered. Several animations and a xref:System.Windows.Media.Animation.Storyboard are created. The storyboard's xref:System.Windows.Media.Animation.Storyboard.Begin%2A method is used to start the animations.
Because button1, button2, and myMainPanel all share the same name scope, any one of them can be used with the xref:System.Windows.Media.Animation.Storyboard xref:System.Windows.Media.Animation.Storyboard.Begin%2A method to start the animations.
Example
[!code-csharpStoryboardBeginAnimation_procedural_snip#NameScopeExample] [!code-vbStoryboardBeginAnimation_procedural_snip#NameScopeExample]