2017-11-08 2 views
0

를 업데이트하지 목록에 바인딩 : 때 toDelete 변경 업데이트되지내용은 다음과 같이 내보기에 나는 버튼이

<Button Style="{StaticResource DeleteButton}" Content="{Binding toDelete, Converter={StaticResource DeleteButtonContentConverter}}" Command="{Binding DeleteCommand}" Grid.Row="0" Grid.Column="4"/> 

합니다. 뷰가 처음로드 될 때 텍스트가 올바르게 표시되기 때문에 (그리고 두 방법으로 모두 작동하도록 하드 코드 할 때) 내 변환기가 작동하는 것을 알고 있습니다.

private List<AppList> _appList; 
    public List<AppList> appList 
    { 
     get { return _appList; } 
     set { Set(ref _appList, value); Log.Debug("appList changed"); } 
    } 

나는 문제가 발생되고 있음을 가정 : 나는 GUI가 내 기록이 로그에 온하지만 직접 알림을 테스트하는 방법을 잘이기 때문에 변경 목록을 통지받은 것으로 가정 버튼은 ItemsControl에 바인딩 된 목록의 일부이지만 List에서 객체의 속성을 업데이트하는 방법을 알아낼 수 없습니다.

테스트로 버튼을 클릭 할 때 발생하는 이벤트를 만들었고 (클릭하면 버튼 자체의 내용이 변경되어야 함) RaisePropertyChanged를 사용하여 List 및 바인딩 된 속성에 대한 변경 사항을 알리려고했습니다 콘텐츠 자체. 어느 쪽도 효과가 없었다. 는 ItemsControl을위한 WPF를하는 데 도움이 경우

은 다음과 같습니다 toDelete 속성이 새로운 값으로 설정 될 때마다 AppList 클래스는 PropertyChanged 이벤트를 INotifyPropertyChanged 인터페이스를 구현하고 인상해야

<ScrollViewer Style="{StaticResource ScrollviewerStyle}" Grid.Row="2"> 
     <ItemsControl ItemsSource="{Binding appList}"> 
      <ItemsControl.ItemTemplate> 
       <DataTemplate> 
        <Border Style="{StaticResource ItemsControlBorderStyle}"> 
         <Grid Width="540"> 
          <Grid.RowDefinitions> 
           <RowDefinition Height="40"/> 
          </Grid.RowDefinitions> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="50"/> 
           <ColumnDefinition Width="100"/> 
           <ColumnDefinition Width="50"/> 
           <ColumnDefinition Width="255"/> 
           <ColumnDefinition Width="70"/> 
          </Grid.ColumnDefinitions> 
          <Label Style="{StaticResource LabelStyle}" Content="Alias:" Grid.Row="0" Grid.Column="0"/> 
          <TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding alias, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="100" Grid.Row="0" Grid.Column="1"/> 
          <Label Style="{StaticResource LabelStyle}" Content="Path:" Grid.Row="0" Grid.Column="2"/> 
          <TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding path, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="255" Grid.Row="0" Grid.Column="3"/> 
          <Button Style="{StaticResource DeleteButton}" Content="{Binding toDelete, Converter={StaticResource DeleteButtonContentConverter}}" Command="{Binding DeleteCommand}" Grid.Row="0" Grid.Column="4"/> 
         </Grid> 
        </Border> 
       </DataTemplate> 
      </ItemsControl.ItemTemplate> 
     </ItemsControl> 
    </ScrollViewer> 
+0

AppList 클래스가 INotifyPropertyChanged를 구현합니까? – mm8

답변

1

.

그러면 변환기가 속성이 설정 될 때마다 호출되어야하며 ButtonContent은 변환기가 반환하는 값으로 설정되어야합니다.

+0

MVVM Light를 사용하고 있기 때문에 대신 ObservableObject를 구현했으며, INotifyPropertyChanged를 구현합니다. 그렇지 않으면 정확히 찾고있는 것입니다. 감사합니다! – Exitialis