1
有沒有辦法從編程生成的綁定中獲取錯誤消息?我只看到例如狀態「PathError」,但不是它失敗的原因。從WPF BindingExpression獲取錯誤消息
var binding = new Binding(path);
var expression = BindingOperations.SetBinding(this, TestProperty, binding);
if (expression.Status == BindingStatus.PathError)
{
throw new Exception("Invalid binding!"); //why did the binding fail?
}
依賴性屬性被定義爲
private static readonly DependencyProperty TestProperty =
DependencyProperty.Register("Test", typeof(object), typeof(DashboardShape));
亞歷
我已經將它設置爲Warning,但沒有顯示(大概是因爲綁定沒有在xaml代碼中設置 - 它是動態的)。此外,我正在尋找一種方法來查看代碼中的錯誤來記錄它。 – LionAM 2014-09-04 11:28:24