BindingGroup.UpdateSources 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
바인딩 및 ValidationRule 속성이 ValidationStep 설정된 RawProposedValueConvertedProposedValue개체에서 변환기를 실행하거나 UpdatedValue 모든 유효성 검사 규칙이 성공하면 대상 값을 원본 개체에 저장합니다.
public:
bool UpdateSources();
public bool UpdateSources();
member this.UpdateSources : unit -> bool
Public Function UpdateSources () As Boolean
반품
예제
다음 예제는 사용자에게 여러 고객을 입력하고 각 고객에게 영업 담당자를 할당하라는 메시지를 표시하는 애플리케이션의 일부입니다. 애플리케이션은 영업 담당자와 고객이 동일한 지역에 속하는지 확인합니다. 이 예제에서는 바인딩의 유효성을 검사하고 모든 유효성 검사 규칙이 성공하면 해당 값을 원본에 저장하도록 호출 UpdateSources 합니다.
void saveCustomer_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
FrameworkElement container = (FrameworkElement) customerList.ContainerFromElement(btn);
// If the user is trying to change an items, when another item has an error,
// display a message and cancel the currently edited item.
if (bindingGroupInError != null && bindingGroupInError != container.BindingGroup)
{
MessageBox.Show("Please correct the data in error before changing another customer");
container.BindingGroup.CancelEdit();
return;
}
if (container.BindingGroup.UpdateSources())
{
bindingGroupInError = null;
MessageBox.Show("Item Saved");
}
else
{
bindingGroupInError = container.BindingGroup;
}
}
Private Sub saveCustomer_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim btn As Button = TryCast(sender, Button)
Dim container As FrameworkElement = CType(customerList.ContainerFromElement(btn), FrameworkElement)
' If the user is trying to change an items, when another item has an error,
' display a message and cancel the currently edited item.
If bindingGroupInError IsNot Nothing AndAlso bindingGroupInError IsNot container.BindingGroup Then
MessageBox.Show("Please correct the data in error before changing another customer")
container.BindingGroup.CancelEdit()
Return
End If
If container.BindingGroup.UpdateSources() Then
bindingGroupInError = Nothing
MessageBox.Show("Item Saved")
Else
bindingGroupInError = container.BindingGroup
End If
End Sub
설명
이 메서드는 성공하는 경우 ValidationRule 원본을 업데이트하지만 원본이 보류 중인 변경 내용을 커밋하고 편집 트랜잭션을 종료하지는 않습니다. 즉, 원본 개체가 구현하는 경우입니다.IEditableObject 이 메서드를 호출해도 호출되지 않습니다 EndEdit . 이 메서드를 CommitEdit 사용하여 원본이 보류 중인 변경 내용을 커밋하도록 합니다.