Tôi có một điều khiển tab với 3 đối tượng, 2 danh sách và một hộp văn bản. Hộp văn bản là ràng buộc hai cách:Hộp văn bản liên kết hai chiều không kích hoạt
<TabControl x:Name="tcTabs" ItemsSource="{Binding Rooms, UpdateSourceTrigger=PropertyChanged}" Margin="5" BorderThickness="1" IsSynchronizedWithCurrentItem="True">
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem">
<Setter Property="Header" Value="{Binding Name}" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding ReceivedMessages}" DisplayMemberPath="Raw" Grid.Row="0" Grid.Column="0" BorderThickness="0" />
<ListBox ItemsSource="{Binding Users}" DisplayMemberPath="Nick" Visibility="{Binding Type, Converter={StaticResource UserListVisibilityConverter}}" Grid.Row="0" Grid.Column="1" BorderThickness="1,0,0,0" BorderBrush="#FFBBBBBB" Width="130" />
<TextBox Text="{Binding CurrentInput, Mode="TwoWay"}" Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0,1,0,0" BorderBrush="#FFBBBBBB" Height="22" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.ItemContainerStyle>
</TabControl>
đối tượng lưng:
public string CurrentInput
{
get
{
return _currentInput;
}
set
{
if (value != _currentInput)
{
_currentInput = value;
OnPropertyChanged();
}
}
}
Vấn đề là, khi tôi thay đổi các văn bản và nhấp vào tab khác nó không cập nhật các lĩnh vực sao lưu (thậm chí không nhấn setter), tuy nhiên nếu tôi thay đổi thì hãy nhấp vào hộp danh sách ...
Bất kỳ lý do nào cho hành vi kỳ quặc này?
này cũng có thể là nguyên nhân của không điểm của tài sản trong phương pháp OnPropertyChanged như 'OnPropertyChanged ("CurrentInput") '. Vui lòng bỏ qua nếu đã thử điều này. –