Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0wpf@3306 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
18 changed files with 284 additions and 59 deletions
@ -0,0 +1,11 @@ |
|||||||
|
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:sys="clr-namespace:System;assembly=mscorlib" |
||||||
|
Name="root" |
||||||
|
Title="Hydralisk"> |
||||||
|
<Window.Resources> |
||||||
|
<sys:String x:Key="r1">Title</sys:String> |
||||||
|
<sys:String x:Key="r2">Width</sys:String> |
||||||
|
</Window.Resources> |
||||||
|
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" /> |
||||||
|
</Window> |
@ -0,0 +1,91 @@ |
|||||||
|
using System; |
||||||
|
using NUnit.Framework; |
||||||
|
using System.Windows.Markup; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Tests.XamlDom |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class MarkupExtensionTests : TestHelper |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void Test1() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Title=\"{Binding}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test2() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Title=\"{Binding Some}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test3() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Title=\"{ Binding Some , ElementName = Some , Mode = TwoWay }\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test4() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Content=\"{x:Type Button}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test5() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Content=\"{t:MyExtension 1, 2}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test6() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Background=\"{x:Static SystemColors.ControlBrush}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test7() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Background=\"{DynamicResource {x:Static SystemColors.ControlBrushKey}}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void Test8() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Content=\"{Binding Some, RelativeSource={RelativeSource Self}}\""); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
[ExpectedException] // Must differ from official XamlReader result
|
||||||
|
public void Test9() |
||||||
|
{ |
||||||
|
TestMarkupExtension("Content=\"{x:Static t:MyStaticClass.StaticString}\""); |
||||||
|
} |
||||||
|
|
||||||
|
static void TestMarkupExtension(string s) |
||||||
|
{ |
||||||
|
TestLoading(@"<Window
|
||||||
|
xmlns=""http://schemas.microsoft.com/netfx/2007/xaml/presentation""
|
||||||
|
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
|
||||||
|
xmlns:t=""" + XamlTypeFinderTests.XamlDomTestsNamespace + @""" |
||||||
|
" + s + @"/>");
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static class MyStaticClass |
||||||
|
{ |
||||||
|
public static string StaticString = "a"; |
||||||
|
} |
||||||
|
|
||||||
|
public class MyExtension : MarkupExtension |
||||||
|
{ |
||||||
|
public MyExtension(object p1, object p2) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public override object ProvideValue(IServiceProvider serviceProvider) |
||||||
|
{ |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue