这段代码有什么问题。我完全一无所知。
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Windows.Data;
namespace CustomControls
{
public class PercentFiller: StackPanel
{
public Rectangle _FillerRectangle = null;
public PercentFiller()
{
_FillerRectangle = new Rectangle();
_FillerRectangle.Height = this.Height;
_FillerRectangle.Width = 20;
_FillerRectangle.SetBinding(Rectangle.FillProperty, new Binding() {
Source = this,
Path = new PropertyPath("FillColorProperty"),
Mode = BindingMode.TwoWay
});
this.Background = new SolidColorBrush(Colors.LightGray);
this.Children.Add(_FillerRectangle);
this.UpdateLayout();
}
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register(
"FillColor",
typeof(Brush),
typeof(Compressor),
new PropertyMetadata(new SolidColorBrush(Color.FromArgb(255, 134, 134, 134))));
[Description("Gets or sets the fill color")]
public Brush FillColor
{
get { return (Brush) GetValue(FillColorProperty); }
set { SetValue (FillColorProperty, value); }
}
}
}
当我将此控件添加到另一个项目时,没有显示矩形控件。请有人帮我解决这个问题。