Browse Source

Hiding/Showing the element when IsHidden property is set/cleared is now handled centrally in DesignTimeProperties.cs.

This fixes the following bugs:

Bindings/Converters on the Visibility property was triggered and replaced the value set by OutlineNodeBase.cs.
Changes on Visibility property ignored IsHidden setting, for example if IsHidden was true and changing Visibility to Visible would then make it Visible.
pull/664/head
gumme 10 years ago
parent
commit
13b5a63303
  1. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs
  2. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignTimeProperties.cs

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs

@ -40,7 +40,6 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -40,7 +40,6 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{ }
if (hidden) {
_isDesignTimeVisible = false;
((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden;
}
bool locked = false;
@ -112,9 +111,6 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -112,9 +111,6 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
set
{
_isDesignTimeVisible = value;
var ctl = DesignItem.Component as UIElement;
if(ctl!=null)
ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden;
RaisePropertyChanged("IsDesignTimeVisible");

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignTimeProperties.cs

@ -16,6 +16,8 @@ @@ -16,6 +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.ComponentModel;
using System.Windows;
namespace ICSharpCode.WpfDesign.XamlDom
@ -47,7 +49,35 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -47,7 +49,35 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// Design-time IsHidden property
/// </summary>
public static readonly DependencyProperty IsHiddenProperty =
DependencyProperty.RegisterAttached("IsHidden", typeof(bool), typeof(DesignTimeProperties));
DependencyProperty.RegisterAttached("IsHidden", typeof(bool), typeof(DesignTimeProperties), new PropertyMetadata(new PropertyChangedCallback(OnIsHiddenPropertyChanged)));
static void OnIsHiddenPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var dpd = DependencyPropertyDescriptor.FromProperty(UIElement.VisibilityProperty, d.GetType());
if ((bool)e.NewValue) {
EnsureHidden(d);
dpd.AddValueChanged(d, OnVisibilityPropertyChanged);
} else {
dpd.RemoveValueChanged(d, OnVisibilityPropertyChanged);
d.InvalidateProperty(UIElement.VisibilityProperty);
}
}
static void OnVisibilityPropertyChanged(object sender, EventArgs e)
{
var d = sender as DependencyObject;
if (d != null && GetIsHidden(d)) {
EnsureHidden(d);
}
}
static void EnsureHidden(DependencyObject d)
{
if (Visibility.Visible.Equals(d.GetValue(UIElement.VisibilityProperty))) {
d.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Hidden);
}
}
#endregion

Loading…
Cancel
Save