전체 바인딩 된 개체가 변환기로 전달되는 ListBox가 있고 (필요한 경우) 개체가 올바르게 업데이트되지 않는 것 같습니다. 여기에 데이터 모델에서 관련 XAML변환기가있는 전체 개체를 텍스트로 바인딩
<TextBlock
Text="{Binding Converter={StaticResource DueConverter}}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneDisabledBrush}" />
그리고 변환기
public class DueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null) return null;
Task task = (Task)value;
if (task.HasReminders)
{
return task.Due.Date.ToShortDateString() + " " + task.Due.ToShortTimeString();
}
else
{
return task.Due.Date.ToShortDateString();
}
}
//Called with two-way data binding as value is pulled out of control and put back into the property
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
그리고 마지막으로 인해 날짜 시간입니다.
private DateTime _due;
[Column(CanBeNull=false)]
public DateTime Due
{
get { return _due; }
set
{
if (_due != value)
{
NotifyPropertyChanging("Due");
_due = value;
NotifyPropertyChanged("Due");
}
}
}
NotifyPropertyChanging/변경 작업, 다른 속성에 바인딩 된 다른 컨트롤이 제대로 업데이트 때문이다.
내 목표는 만기가 변경되었을 때 만기일 TextBlock을 업데이트하는 것입니다. 그러나 출력의 형식은 Task 개체의 다른 속성에 따라 다릅니다.
의견이 있으십니까?
일반적으로 SO 프로토콜은 질문 제목에 태그를 넣지 않는 것입니다. 제목을 업데이트하고 질문에 다시 태그를 답니다. –
그렇게 해 주셔서 감사합니다. – upopple