diff --git a/samples/XamlDesigner/App.xaml.cs b/samples/XamlDesigner/App.xaml.cs
index 6a9be5c98c..5d9484dadf 100644
--- a/samples/XamlDesigner/App.xaml.cs
+++ b/samples/XamlDesigner/App.xaml.cs
@@ -31,9 +31,16 @@ namespace ICSharpCode.XamlDesigner
private static bool internalLoad = false;
private static string lastRequesting = null;
-
+
Assembly AppDomain_CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
+ var assList = AppDomain.CurrentDomain.GetAssemblies();
+ var loaded = assList.FirstOrDefault(x => x.FullName == args.Name);
+ if (loaded != null)
+ {
+ return loaded;
+ }
+
if (internalLoad)
return null;
@@ -48,7 +55,7 @@ namespace ICSharpCode.XamlDesigner
ass = Assembly.Load(args.Name);
}
catch (Exception) { }
-
+
if (ass == null && args.RequestingAssembly != null) {
lastRequesting = args.RequestingAssembly.Location;
var dir = Path.GetDirectoryName(args.RequestingAssembly.Location);
@@ -68,7 +75,7 @@ namespace ICSharpCode.XamlDesigner
}
internalLoad = false;
-
+
return ass;
}
diff --git a/samples/XamlDesigner/DocumentView.xaml b/samples/XamlDesigner/DocumentView.xaml
index 06f45a450f..760bb699b9 100644
--- a/samples/XamlDesigner/DocumentView.xaml
+++ b/samples/XamlDesigner/DocumentView.xaml
@@ -13,10 +13,10 @@
+ Visibility="{Binding InDesignMode, Converter={StaticResource CollapsedWhenFalse}}"/>
\ No newline at end of file
diff --git a/samples/XamlDesigner/DocumentView.xaml.cs b/samples/XamlDesigner/DocumentView.xaml.cs
index fad8fa09f4..755ba648d1 100644
--- a/samples/XamlDesigner/DocumentView.xaml.cs
+++ b/samples/XamlDesigner/DocumentView.xaml.cs
@@ -25,7 +25,7 @@ namespace ICSharpCode.XamlDesigner
InitializeComponent();
Document = doc;
- Shell.Instance.Views[doc] = this;
+ Shell.Instance.Views[doc] = this;
//uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
Document.Mode = DocumentMode.Design;
@@ -52,7 +52,15 @@ namespace ICSharpCode.XamlDesigner
try {
uxTextEditor.ScrollTo(error.Line, error.Column);
uxTextEditor.CaretOffset = uxTextEditor.Document.GetOffset(error.Line, error.Column);
- } catch (ArgumentException) {
+
+ int n = 0;
+ char chr;
+ while ((chr = uxTextEditor.Document.GetCharAt(uxTextEditor.CaretOffset + n)) != ' ' && chr != '.' && chr != '<' && chr != '>' && chr != '"')
+ { n++; }
+
+ uxTextEditor.SelectionLength = n;
+ }
+ catch (ArgumentException) {
// invalid line number
}
}
diff --git a/samples/XamlDesigner/ErrorListView.xaml b/samples/XamlDesigner/ErrorListView.xaml
index fa661fa0e3..158a26f25e 100644
--- a/samples/XamlDesigner/ErrorListView.xaml
+++ b/samples/XamlDesigner/ErrorListView.xaml
@@ -2,15 +2,22 @@
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Services="clr-namespace:ICSharpCode.WpfDesign.Designer.Services;assembly=ICSharpCode.WpfDesign.Designer">
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/samples/XamlDesigner/Toolbox.cs b/samples/XamlDesigner/Toolbox.cs
index d4880827a7..b4b400e8c6 100644
--- a/samples/XamlDesigner/Toolbox.cs
+++ b/samples/XamlDesigner/Toolbox.cs
@@ -78,7 +78,7 @@ namespace ICSharpCode.XamlDesigner
static bool IsControl(Type t)
{
- return !t.IsAbstract && !t.IsGenericTypeDefinition && t.IsSubclassOf(typeof(FrameworkElement));
+ return !t.IsAbstract && !t.IsGenericTypeDefinition && t.IsSubclassOf(typeof(UIElement)) && t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) != null;
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
index b4e0a025a1..d3f6b61379 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
@@ -227,8 +227,12 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
var rt = (MatrixTransform) adorner.AdornedElement.TransformToAncestor(_designPanel);
if (adorner.AdornedDesignItem != null && adorner.AdornedDesignItem.Parent != null && adorner.AdornedDesignItem.Parent.View is Canvas && adorner.AdornedElement.RenderSize.Height == 0 && adorner.AdornedElement.RenderSize.Width == 0)
{
- var xOffset = rt.Matrix.OffsetX - (((FrameworkElement)adorner.AdornedElement).Width / 2);
- var yOffset = rt.Matrix.OffsetY - (((FrameworkElement)adorner.AdornedElement).Height / 2);
+ var width = ((FrameworkElement) adorner.AdornedElement).Width;
+ width = width > 0 ? width : 2.0;
+ var height = ((FrameworkElement)adorner.AdornedElement).Height;
+ height = height > 0 ? height : 2.0;
+ var xOffset = rt.Matrix.OffsetX - (width / 2);
+ var yOffset = rt.Matrix.OffsetY - (height / 2);
rt = new MatrixTransform(new Matrix(rt.Matrix.M11, rt.Matrix.M12, rt.Matrix.M21, rt.Matrix.M22, xOffset, yOffset));
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
index 7183b558c4..c1c8fb22c1 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
@@ -117,17 +117,14 @@
-
+
-
-
-
-
+
+
+
+
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
index ef4cf69196..2d7a7462aa 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
@@ -66,15 +66,13 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
}
set { }
}
-
- ///
- /// Specifies the icon to use.
- ///
- public ImageSource Icon {
+
+ public ImageSource Icon
+ {
get { return (ImageSource)GetValue(Window.IconProperty); }
set { SetValue(Window.IconProperty, value); }
}
-
+
///
/// This property has no effect. (for compatibility with only).
///
@@ -93,11 +91,12 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
get { return owner; }
set { owner = value; }
}
-
+
///
/// Gets or sets the resize mode.
///
- public ResizeMode ResizeMode {
+ public ResizeMode ResizeMode
+ {
get { return (ResizeMode)GetValue(Window.ResizeModeProperty); }
set { SetValue(Window.ResizeModeProperty, value); }
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
index 92a11aa73e..101cf285bf 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
@@ -99,7 +99,27 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (value == null || (int)value == 0) {
+ if (value == null || (value is int && (int)value == 0)) {
+ return Visibility.Collapsed;
+ }
+ return Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class CollapsedWhenNotNull : IValueConverter
+ {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
+ public static readonly CollapsedWhenNotNull Instance = new CollapsedWhenNotNull();
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null)
+ {
return Visibility.Collapsed;
}
return Visibility.Visible;
@@ -160,37 +180,37 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
}
}
- public class ControlToRealWidthConverter : IMultiValueConverter
- {
- public static readonly ControlToRealWidthConverter Instance = new ControlToRealWidthConverter();
-
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- return PlacementOperation.GetRealElementSize((UIElement)values[0]).Width;
- }
-
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class ControlToRealHeightConverter : IMultiValueConverter
- {
- public static readonly ControlToRealHeightConverter Instance = new ControlToRealHeightConverter();
-
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- return PlacementOperation.GetRealElementSize((UIElement)values[0]).Height;
- }
-
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-
- public class FormatDoubleConverter : IValueConverter
+ public class ControlToRealWidthConverter : IMultiValueConverter
+ {
+ public static readonly ControlToRealWidthConverter Instance = new ControlToRealWidthConverter();
+
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ return PlacementOperation.GetRealElementSize((UIElement)values[0]).Width;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class ControlToRealHeightConverter : IMultiValueConverter
+ {
+ public static readonly ControlToRealHeightConverter Instance = new ControlToRealHeightConverter();
+
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ return PlacementOperation.GetRealElementSize((UIElement)values[0]).Height;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public class FormatDoubleConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FormatDoubleConverter Instance=new FormatDoubleConverter();
@@ -280,7 +300,36 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
return Enum.Parse(targetType, parameterString);
}
}
-
+
+ public class EnumCollapsed : IValueConverter
+ {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
+ public static readonly EnumCollapsed Instance = new EnumCollapsed();
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ string parameterString = parameter as string;
+ if (parameterString == null)
+ return DependencyProperty.UnsetValue;
+
+ if (Enum.IsDefined(value.GetType(), value) == false)
+ return DependencyProperty.UnsetValue;
+
+ object parameterValue = Enum.Parse(value.GetType(), parameterString);
+
+ return parameterValue.Equals(value) ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ string parameterString = parameter as string;
+ if (parameterString == null)
+ return DependencyProperty.UnsetValue;
+
+ return Enum.Parse(targetType, parameterString);
+ }
+ }
+
public class InvertedZoomConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs
index 54d89a4329..16d56fe81b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/BorderForImageControl.cs
@@ -17,59 +17,55 @@
// DEALINGS IN THE SOFTWARE.
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
-using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
-using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
- [ExtensionFor(typeof(Image))]
- public class BorderForImageControl : PermanentAdornerProvider
+ [ExtensionFor(typeof(Image))]
+ public class BorderForImageControl : PermanentAdornerProvider
{
AdornerPanel adornerPanel;
AdornerPanel cachedAdornerPanel;
- Border border;
-
- protected override void OnInitialized()
+ Border border;
+
+ protected override void OnInitialized()
{
base.OnInitialized();
- this.ExtendedItem.PropertyChanged += OnPropertyChanged;
+ this.ExtendedItem.PropertyChanged += OnPropertyChanged;
- UpdateAdorner();
- }
+ UpdateAdorner();
+ }
- protected override void OnRemove()
- {
- this.ExtendedItem.PropertyChanged -= OnPropertyChanged;
- base.OnRemove();
- }
+ protected override void OnRemove()
+ {
+ this.ExtendedItem.PropertyChanged -= OnPropertyChanged;
+ base.OnRemove();
+ }
- void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (sender == null || e.PropertyName == "Width" || e.PropertyName == "Height")
- {
- ((DesignPanel) this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
- }
- }
+ void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ {
+ if (sender == null || e.PropertyName == "Width" || e.PropertyName == "Height")
+ {
+ ((DesignPanel) this.ExtendedItem.Services.DesignPanel).AdornerLayer.UpdateAdornersForElement(this.ExtendedItem.View, true);
+ }
+ }
- void UpdateAdorner()
+ void UpdateAdorner()
{
var element = ExtendedItem.Component as UIElement;
if (element != null) {
- CreateAdorner();
- }
+ CreateAdorner();
+ }
}
-
+
private void CreateAdorner()
{
if (adornerPanel == null) {
@@ -80,9 +76,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
border = new Border();
border.BorderThickness = new Thickness(1);
border.BorderBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xCC, 0xCC));
- border.Background = Brushes.Transparent;
+ border.Background = Brushes.Transparent;
border.IsHitTestVisible = true;
- border.MouseDown += border_MouseDown;
+ border.MouseDown += border_MouseDown;
+ border.MinWidth = 1;
+ border.MinHeight = 1;
+
AdornerPanel.SetPlacement(border, AdornerPlacement.FillContent);
cachedAdornerPanel.Children.Add(border);
}
@@ -92,15 +91,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
}
}
- void border_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- if (!Keyboard.IsKeyDown(Key.LeftAlt) && ((Image) this.ExtendedItem.View).Source == null)
- {
- e.Handled = true;
- this.ExtendedItem.Services.Selection.SetSelectedComponents(new DesignItem[] {this.ExtendedItem},
- SelectionTypes.Auto);
- ((DesignPanel) this.ExtendedItem.Services.DesignPanel).Focus();
- }
- }
+ void border_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (!Keyboard.IsKeyDown(Key.LeftAlt) && ((Image) this.ExtendedItem.View).Source == null)
+ {
+ e.Handled = true;
+ this.ExtendedItem.Services.Selection.SetSelectedComponents(new DesignItem[] {this.ExtendedItem},
+ SelectionTypes.Auto);
+ ((DesignPanel) this.ExtendedItem.Services.DesignPanel).Focus();
+ }
+ }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.32x32.EmptyProjectIcon.png b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.32x32.EmptyProjectIcon.png
new file mode 100644
index 0000000000..1977344cf2
Binary files /dev/null and b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.32x32.EmptyProjectIcon.png differ
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
index 648b4097ec..bd0df157fa 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
@@ -30,15 +30,26 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
protected OutlineNodeBase(DesignItem designItem)
{
DesignItem = designItem;
-
- var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
+ bool hidden = false;
+ try
+ {
+ hidden = (bool)designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
+ }
+ catch (Exception)
+ { }
if (hidden != null && (bool)hidden) {
_isDesignTimeVisible = false;
((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden;
}
- var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance;
+ bool locked = false;
+ try
+ {
+ locked = (bool)designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance;
+ }
+ catch (Exception)
+ { }
if (locked != null && (bool)locked) {
_isDesignTimeLocked = true;
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml
index 27c3bf591e..3e76908c6d 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml
@@ -192,7 +192,7 @@
-
+
@@ -307,7 +307,7 @@
-
+
@@ -422,7 +422,7 @@
-
+
@@ -575,7 +575,7 @@
-
+
@@ -704,7 +704,7 @@
-
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs
index fc837b3a43..2913fa6bdc 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ThumbnailView/ThumbnailView.cs
@@ -133,7 +133,7 @@ namespace ICSharpCode.WpfDesign.Designer.ThumbnailView
xOffset = 0;
yOffset = 0;
- if (this.DesignSurface.DesignContext != null)
+ if (this.DesignSurface.DesignContext != null && this.DesignSurface.DesignContext.RootItem != null)
{
var designedElement = this.DesignSurface.DesignContext.RootItem.Component as FrameworkElement;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
index cd35d12092..40aadb1395 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
@@ -458,4 +458,7 @@
+
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
index 008a5249d3..736a8ef126 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
@@ -134,7 +134,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
///
public override event EventHandler ParentChanged {
add { _xamlObject.ParentPropertyChanged += value; }
- remove { _xamlObject.ParentPropertyChanged += value; }
+ remove { _xamlObject.ParentPropertyChanged -= value; }
}
public override UIElement View {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
index 8e6d937f6a..e70e3c1a20 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
@@ -107,7 +107,9 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public IEnumerator GetEnumerator()
{
foreach (XamlPropertyValue val in property.CollectionElements) {
- yield return GetItem(val);
+ var item = GetItem(val);
+ if (item != null)
+ yield return item;
}
}
@@ -121,7 +123,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (val is XamlObject) {
return context._componentService.GetDesignItem( ((XamlObject)val).Instance );
} else {
- throw new NotImplementedException();
+ return null; // throw new NotImplementedException();
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Test.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Test.xaml
new file mode 100644
index 0000000000..61820b241f
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Test.xaml
@@ -0,0 +1,3 @@
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
index 141e0a2947..780ad08b4f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
@@ -102,5 +102,9 @@
WpfDesign.Designer
-
+
+
+ Designer
+
+
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
index 7d490b2150..7cc26d38c8 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
@@ -16,7 +16,8 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
-using System;
+using System.IO;
+using ICSharpCode.WpfDesign.XamlDom;
using NUnit.Framework;
namespace ICSharpCode.WpfDesign.Tests.XamlDom
@@ -127,7 +128,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
}
[Test]
- public void Resources()
+ public void Resources1()
{
TestLoading(@"");
}
- [Test]
- public void Resources2()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
+ [Test]
public void Resources3()
{
TestLoading(@"");
}
- [Test]
- public void Resources4()
- {
- TestLoading(@"
@@ -177,8 +178,25 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
");
- }
-
+ }
+
+ [Test]
+ public void Resources5()
+ {
+ TestLoading(@"
+
+
+
+
+
+
+
+ ");
+ }
+
+
[Test]
public void Animation1()
{
@@ -234,7 +252,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
[Test]
public void Animation3()
{
- TestLoading(@"
");
}
- [Test]
- public void ContentControl1()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
- public void ContentControl2()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
- public void Children1()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
- public void Children2()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
- public void Children3()
- {
- TestLoading(@"
");
- }
+ }
- [Test]
- public void ListBox1()
- {
- TestLoading(@"
");
- }
+ }
+ [Test]
+ //[Ignore("To fix this Test, we need a special Handling for Setter class, because MS Xaml Parser casts the Value of a Setter to the PropertyType wich is defined in another Property!")]
+ //Or maybe we need support for XamlSetTypeConverterAttribute, TypeConverterAttribute(typeof(SetterTriggerConditionValueConverter)), ...
+ public void ListBox2()
+ {
+ TestLoading(@"
+
+");
+ }
- [Test]
- public void CData1()
- {
- TestLoading(@"
+
+");
+ }
+
+ [Test]
+ public void Window1()
+ {
+ var xaml= @"
+";
+
+ XamlParser.Parse(new StringReader(xaml));
+ }
+
+ [Test]
+ public void CData1()
+ {
+ TestLoading(@"
");
- }
- }
+ }
+ }
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
index 064a4bb77c..01b71be2f6 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
@@ -85,11 +85,12 @@ namespace ICSharpCode.WpfDesign.XamlDom
} else if (collectionInstance is IDictionary) {
object val = newElement.GetValueFor(null);
object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null;
- //if (key == null || key == "") {
- // if (val is Style)
- // key = ((Style)val).TargetType;
- //}
- if (key == null || (key as string) == "")
+ if (key == null || key == "")
+ {
+ if (val is Style)
+ key = ((Style)val).TargetType;
+ }
+ if (key == null || (key as string) == "")
key = val;
((IDictionary)collectionInstance).Add(key, val);
} else {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
index b517eea9f0..b09468d7c8 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
@@ -219,14 +219,14 @@ namespace ICSharpCode.WpfDesign.XamlDom
return new XamlObject(this, xml, elementType, instance);
}
- internal string GetNamespaceFor(Type type)
+ internal string GetNamespaceFor(Type type, bool getClrNamespace = false)
{
if (type == typeof (DesignTimeProperties))
return XamlConstants.DesignTimeNamespace;
if (type == typeof (MarkupCompatibilityProperties))
return XamlConstants.MarkupCompatibilityNamespace;
- return _typeFinder.GetXmlNamespaceFor(type.Assembly, type.Namespace);
+ return _typeFinder.GetXmlNamespaceFor(type.Assembly, type.Namespace, getClrNamespace);
}
internal string GetPrefixForNamespace(string @namespace)
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
index fbe1131988..1ff20e9a43 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
@@ -22,10 +22,12 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
+using System.Reflection;
using System.Windows.Markup;
using System.Xml;
using System.Windows.Data;
using System.Windows;
+using System.Xaml;
namespace ICSharpCode.WpfDesign.XamlDom
{
@@ -53,6 +55,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
this.instance = instance;
this.contentPropertyName = GetContentPropertyName(elementType);
+ XamlSetTypeConverter = GetTypeConverterDelegate(elementType);
ServiceProvider = new XamlObjectServiceProvider(this);
CreateWrapper();
@@ -70,7 +73,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (property.IsAttached == false) {
foreach (XamlProperty p in properties) {
if (p.IsAttached == false && p.PropertyName == property.PropertyName)
- throw new XamlLoadException("duplicate property");
+ throw new XamlLoadException("duplicate property:" + property.PropertyName);
}
}
#endif
@@ -183,7 +186,36 @@ namespace ICSharpCode.WpfDesign.XamlDom
return null;
}
-
+
+ internal delegate void TypeConverterDelegate(Object targetObject, XamlSetTypeConverterEventArgs eventArgs);
+
+ internal TypeConverterDelegate XamlSetTypeConverter { get; private set; }
+
+ internal static TypeConverterDelegate GetTypeConverterDelegate(Type elementType)
+ {
+ var attrs = elementType.GetCustomAttributes(typeof(XamlSetTypeConverterAttribute), true) as XamlSetTypeConverterAttribute[];
+ if (attrs != null && attrs.Length > 0)
+ {
+ var name = attrs[0].XamlSetTypeConverterHandler;
+ var method=elementType.GetMethod(name, BindingFlags.Static|BindingFlags.Public|BindingFlags.NonPublic);
+
+ return (TypeConverterDelegate) TypeConverterDelegate.CreateDelegate(typeof(TypeConverterDelegate), method);
+ }
+
+ return null;
+ }
+
+ private XamlType _systemXamlTypeForProperty = null;
+ public XamlType SystemXamlTypeForProperty
+ {
+ get
+ {
+ if (_systemXamlTypeForProperty == null)
+ _systemXamlTypeForProperty = new XamlType(this.ElementType, this.ServiceProvider.SchemaContext);
+ return _systemXamlTypeForProperty;
+ }
+ }
+
internal override void AddNodeTo(XamlProperty property)
{
XamlObject holder;
@@ -353,7 +385,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// Gets/Sets the name of this XamlObject.
///
public string Name {
- get
+ get
{
string name = GetXamlAttribute("Name");
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
index e32e261e3e..1b05165a23 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
@@ -29,7 +29,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// A service provider that provides the IProvideValueTarget and IXamlTypeResolver services.
/// No other services (e.g. from the document's service provider) are offered.
///
- public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget, IXamlSchemaContextProvider, IAmbientProvider
+ public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget, IXamlSchemaContextProvider, IAmbientProvider
{
///
/// Creates a new XamlObjectServiceProvider instance.
@@ -61,12 +61,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (serviceType == typeof(IXamlTypeResolver)) {
return Resolver;
}
- if (serviceType == typeof(IXamlSchemaContextProvider)) {
- return this;
- }
- if (serviceType == typeof(IAmbientProvider)) {
- return this;
- }
+ if (serviceType == typeof(XamlTypeResolverProvider))
+ {
+ return Resolver;
+ }
+ if (serviceType == typeof(IXamlSchemaContextProvider)) {
+ return this;
+ }
+ if (serviceType == typeof(IAmbientProvider)) {
+ return this;
+ }
return null;
}
@@ -110,57 +114,72 @@ namespace ICSharpCode.WpfDesign.XamlDom
#endregion
- #region IXamlSchemaContextProvider Members
-
- private XamlSchemaContext iCsharpXamlSchemaContext;
-
- //Maybe we new our own XamlSchemaContext?
- //private class ICsharpXamlSchemaContext : XamlSchemaContext
- //{
- // public override XamlType GetXamlType(Type type)
- // {
- // return base.GetXamlType(type);
- // }
- //}
-
- public XamlSchemaContext SchemaContext
- {
- get
- {
- return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? new XamlSchemaContext();
- }
- }
-
- #endregion
-
- #region IAmbientProvider Members
-
- public AmbientPropertyValue GetFirstAmbientValue(IEnumerable ceilingTypes, params XamlMember[] properties)
- {
- return null;
- }
-
- public object GetFirstAmbientValue(params XamlType[] types)
- {
- return null;
- }
-
- public IEnumerable GetAllAmbientValues(IEnumerable ceilingTypes, params XamlMember[] properties)
- {
- return new List();
- }
-
- public IEnumerable