【发布时间】:2014-02-17 12:26:37
【问题描述】:
我正在尝试关注这个article,唯一的区别是我在后面的代码中创建和绑定控件。 不幸的是,它不起作用。这是我的示例代码:
public partial class ShellWindow
{
private static Visibility progressbarVisibility = Visibility.Collapsed;
public static Visibility ProgressbarVisibility
{
get { return progressbarVisibility; }
set
{
if (progressbarVisibility == value) return;
progressbarVisibility = value;
RaiseStaticPropertyChanged("ProgressbarVisibility");
}
}
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
public static void RaiseStaticPropertyChanged(string propName)
{
EventHandler<PropertyChangedEventArgs> handler = StaticPropertyChanged;
if (handler != null)
handler(null, new PropertyChangedEventArgs(propName));
}
}
我是这样绑定的
var binding = new Binding("ShellWindow.ProgressbarVisibility") { Mode = BindingMode.TwoWay };
progressbar = new CircularProgressBar ();
progressbar.SetBinding(VisibilityProperty,
binding);
我想我遗漏了一些东西,但我不确定我错在哪里。 任何帮助都会很棒。
【问题讨论】: