Skip to content

Instantly share code, notes, and snippets.

@jacksonh
Created August 17, 2010 21:05
Show Gist options
  • Save jacksonh/532024 to your computer and use it in GitHub Desktop.
Save jacksonh/532024 to your computer and use it in GitHub Desktop.
[TestMethod]
[Asynchronous]
public void ChangeContentChangesTemplate ()
{
ContentControl c = (ContentControl) XamlReader.Load (@"
<ContentControl xmlns=""http://schemas.microsoft.com/client/2007"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<ContentControl.Template>
<ControlTemplate>
<Grid>
<ContentPresenter />
</Grid>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
");
// Check what happens going from UIElement -> UIElement
c.Content = new Rectangle ();
c.ApplyTemplate ();
CreateAsyncTest (c,
() => Assert.VisualChildren (c, "#1",
new VisualNode<Grid> ("#a",
new VisualNode<ContentPresenter> ("#b",
new VisualNode<Rectangle> ("#c")
)
)
),
() => {
c.Content = new Rectangle ();
Assert.VisualChildren (c, "#3",
new VisualNode<Grid> ("#d",
new VisualNode<ContentPresenter> ("#e")
)
);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment