1
XAML 코드에서 바인더 제본 제어 업데이트 할 수 없습니다 PhysicalDeliveryParametersDlg (대화 상자가 나타납니다실버보기
<TextBlock Text="Country" Foreground="white" TextAlignment="Right" Grid.Row="2" Grid.Column="0" />
<TextBox
x:Name="txtCountries"
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
Margin="2, 2, 2, 2"
Text="{Binding PhysicalDeliveryParameters.Countries, Converter={StaticResource EnumerableToTextConverter}, ConverterParameter='...'}"
IsReadOnly="True">
</TextBox>
<Button
Grid.Row="2"
Grid.Column="3"
Content="..."
HorizontalAlignment="Left"
Tag="Countries"
Click="ButtonBase_OnClick" />
C# 코드 :
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
PhysicalDeliveryParametersViewModel pvm = GetViewModel();
GenericObservableCollection<SelectableItem> items = pvm.Countries;
PhysicalDeliveryParametersDlg dlg = new PhysicalDeliveryParametersDlg(items);
dlg.Closed += (o, args) =>
{
BindingExpression binding = txtCountries.GetBindingExpression(TextBox.TextProperty);
if(null != binding)
binding.UpdateSource();
};
dlg.ShowDialog();
}
내가 버튼을 클릭
에서, ButtonBase_OnClick() 메소드가 실행을 클래스)를 선택하고 몇 가지 값을 선택합니다. 바인딩 된 데이터 (ObservableCollection 인 PhysicalDeliveryParameters.Countries)는 업데이트되지만 TextBox의 Text 속성은 업데이트되지 않았습니다. 내가 잘못 했습니까?추신 : 저는 Silverlight에서 모달 윈도우를 만드는 데 가장 좋은 방법을 사용하고 있는지 잘 모르겠습니다. 조언을 해줄 수 있습니까?
이것은 내가 사용하는 솔루션입니다. 하지만 더 좋고/깨끗한 것을 가지고 싶습니다 :-( – schglurps
@schglurps 무엇이 좋지 않다고/더러운 것 같습니까? 실제로 바인딩을 사용하는 대신 수동으로 국가 문자열을 업데이트한다는 사실 은요? – McGarnagle