You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Text; |
|
using System.Windows.Controls; |
|
using System.Windows; |
|
|
|
namespace SharpDevelop.XamlDesigner.Controls |
|
{ |
|
public class LayersPanel : Grid |
|
{ |
|
public static readonly DependencyProperty SelectedIndexProperty = |
|
DependencyProperty.Register("SelectedIndex", typeof(int), typeof(LayersPanel)); |
|
|
|
public int SelectedIndex |
|
{ |
|
get { return (int)GetValue(SelectedIndexProperty); } |
|
set { SetValue(SelectedIndexProperty, value); } |
|
} |
|
|
|
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) |
|
{ |
|
base.OnPropertyChanged(e); |
|
if (e.Property == SelectedIndexProperty) { |
|
UpdateVisibility(); |
|
} |
|
} |
|
|
|
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) |
|
{ |
|
base.OnVisualChildrenChanged(visualAdded, visualRemoved); |
|
UpdateVisibility(); |
|
} |
|
|
|
void UpdateVisibility() |
|
{ |
|
for (int i = 0; i < Children.Count; i++) { |
|
if (i == SelectedIndex) { |
|
Children[i].Visibility = Visibility.Visible; |
|
} |
|
else { |
|
Children[i].Visibility = Visibility.Hidden; |
|
} |
|
} |
|
} |
|
} |
|
}
|
|
|