전공/WPF 삽질들..
system.windows.data error: 23
무한공백
2014. 3. 21. 15:07
ImagePath가 null 또는 "" 일경우
system.windows.data error: 23 Cannot convert '' from type '' to type ... 와 같은 에러가 난다.
이럴 경우 바인딩된 변수를 아래와 같이 해결하면 에러가 나지 않는다.![]()
private string _imagePath = string.Empty; public object ImagePath { get { if (string.IsNullOrEmpty(_imagePath)) return DependencyProperty.UnsetValue; return _imagePath; } set { if (!(value is string)) return; _imagePath = value.ToString(); OnPropertyChanged("ImagePath"); } }