BindingGroup.UpdateSources 메서드

정의

ValidationRule 속성이 ValidationStep, RawProposedValue 또는 ConvertedProposedValue로 설정된 UpdatedValue 개체 및 바인딩에 대해 변환기를 실행하고 모든 유효성 검사 규칙이 성공하는 경우 대상의 값을 소스 개체에 저장합니다.

public:
 bool UpdateSources();
public bool UpdateSources ();
member this.UpdateSources : unit -> bool
Public Function UpdateSources () As Boolean

반환

Boolean

모든 유효성 검사 규칙이 성공하면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제는 여러 고객을 입력 하 고 각 고객에 게는 영업 담당자를 할당 하 라는 메시지는 애플리케이션의 일부입니다. 애플리케이션 판매 담당자와 고객 동일한 지역에 속해 있는지 확인 합니다. 예제에서는 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 메서드를 사용 하려면 소스 보류 중인 변경 내용을 커밋합니다.

적용 대상