Created
August 10, 2010 18:03
-
-
Save jacksonh/517704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// if the textblock is in a managed control like the grid, | |
// its legal to set FontWeights with an int. | |
// | |
Grid grid = XamlReader.Load (@"<Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" | |
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> | |
<TextBlock x:Name=""the_box"" FontWeight=""600"" /> | |
</Grid>") as Grid; | |
Assert.IsNotNull (grid, "a1"); | |
TextBlock block = grid.FindName ("the_box") as TextBlock; | |
Assert.IsNotNull (block, "a2"); | |
Assert.AreEqual (FontWeights.SemiBold, block.FontWeight, "a3"); | |
// | |
// But we can't just do this normally. | |
// | |
string bad_xaml = @"<TextBlock xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" | |
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""> | |
FontWeight=""600"" />"; | |
Assert.Throws<XamlParseException> (() => XamlReader.Load (bad_xaml)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment