Skip to content

Commit

Permalink
fix: Unable to refresh after loading all the historical records.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZGGSONG committed Jan 31, 2024
1 parent a02cd03 commit a4431da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions STranslate/ViewModels/Preference/HistoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public HistoryViewModel()
/// 2. 在搜索过程中
/// 3. view列表总数等于数据库总数
/// </summary>
private bool CanLoadHistory => !IsLoading && string.IsNullOrEmpty(SearchContent) && (Count == 0 || HistoryList.Count != Count);
public bool CanLoadHistory => !IsLoading && string.IsNullOrEmpty(SearchContent) && (Count == 0 || HistoryList.Count != Count);

[RelayCommand(CanExecute = nameof(CanLoadHistory))]
[RelayCommand]
private async Task LoadMoreHistoryAsync(ScrollViewer? scroll)
{
IsLoading = true;
Expand Down
2 changes: 1 addition & 1 deletion STranslate/Views/Preference/HistoryPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
SelectedIndex="{Binding SelectedIndex}">
<ListBox.ContextMenu>
<ContextMenu Width="120">
<MenuItem Command="{Binding LoadMoreHistoryCommand}"
<MenuItem Command="{Binding Source={StaticResource vm}, Path=Data.LoadMoreHistoryCommand}"
CommandParameter="{Binding Source={StaticResource scroll}, Path=Data}"
FontFamily="{DynamicResource IconFont}"
Header="刷新记录"
Expand Down
2 changes: 1 addition & 1 deletion STranslate/Views/Preference/HistoryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void HistoryListBox_ScrollChanged(object sender, ScrollChangedEventArgs
//);

// 滚动到底 && command执行条件允许才能执行
if (!atBottom || !vm.LoadMoreHistoryCommand.CanExecute(null))
if (!atBottom || !vm.CanLoadHistory)
return;

// 已经到达底部,执行刷新操作
Expand Down

0 comments on commit a4431da

Please sign in to comment.