Hi everybody,
The question may seem easy, but I found some little problems in fetching all and just properties defined in the high-level hierarcy (it means I do not want inherited properties to be get by this method).
This is the class:
public partial class GUIButton : CloneableGUIElement
{
private Rect _position;
public Rect Position
{
get { return _position; }
set
{
Canvas.SetLeft(this, value.X);
Canvas.SetTop(this, value.Y);
this.Height = value.Height;
this.Width = value.Width;
_position = value;
}
}
private string _text;
public string Text
{
get { return _text; }
set
{
this.Button.Content = value;
_text = value;
}
}
private string _image;
public string Image
{
get { return _image; }
set
{
VisualBrush b = new VisualBrush(new Image() { Source = new BitmapImage(new Uri(value)), Stretch = Stretch.Fill });
this.Button.Background = b;
_image = value;
}
}
public override object Clone()
{
return new GUIButton(this.Position, this.Text, this.Image);
}
public GUIButton()
{
InitializeComponent();
}
public GUIButton(Rect position, string text, string image)
{
InitializeComponent();
Position = position;
Text = text;
Image = image;
}
}
Where
CloneableGUIElement
derives from UserControl.
I tried this
PropertyInfo[] PIs = typeof(GUIButton).GetProperties(BindingFlags.DeclaredOnly);
but the array is empty. It remains empty even if I put whatever BindingFlag as argument (I've checked), but it returns 106 properties (inherited and not inherited ones) if I do not use any BindingFlag conditions...
How can I get just Position, Text and Image from GUIButton?
Thanks a lot!!
LG