Skip to content

Commit

Permalink
#1047 修复快捷键设置项宽度不更新
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Feb 16, 2025
1 parent 47421a3 commit 567cc6b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
MaxWidth="1200"
Margin="0,0,0,8"
x:Name="ShortcutKeySettingPanel"
Orientation="Vertical">
Orientation="Vertical"
SizeChanged="ShortcutKeySettingPanel_OnSizeChanged">
<controls:SettingsCard Description="选择鼠标中键/侧键行为" Header="鼠标自定义">
<controls:SettingsCard.HeaderIcon>
<font:FontAwesome Icon="Solid_Mouse" />
Expand All @@ -44,15 +45,14 @@
</Grid>
<ListView
Padding="-12,0"
Width="{Binding ActualWidth, ElementName=ShortcutKeySettingPanel}"
Width="{x:Bind m_viewModel.ControlWidth,Mode=OneWay}"
MinWidth="320"
ItemsSource="{x:Bind m_viewModel.ShortcutFunctions, Mode=OneWay}"
SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate x:DataType="settings:ShortcutFunctionViewModel">
<controls:SettingsExpander Description="{x:Bind Description}" Header="{x:Bind Name}"
MinWidth="320"
Width="{Binding ActualWidth, ElementName=ShortcutKeySettingPanel}">
MinWidth="320" Width="{Binding DataContext.ControlWidth,ElementName=ShortcutKeySettingPanel,Mode=OneWay}">
<controls:SettingsExpander.HeaderIcon>
<font:FontAwesome Icon="Solid_Keyboard" />
</controls:SettingsExpander.HeaderIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public ShortcutKeySettingsControl()
m_viewModel = App.ServiceProvider.GetRequiredService<ShortcutKeySettingsControlViewModel>();
m_viewModel.ShortcutFunctions = m_mapper.Map<ObservableCollection<ShortcutFunctionViewModel>>(m_shortcutKeyService.ShortcutFunctions);
m_viewModel.PressActionDelayTime = m_shortcutKeyService.PressActionDelayTime;
DataContext = m_viewModel;
InitializeComponent();

m_shortcutKeyService.OnRecordKeyDown += ShortcutKeyService_OnRecordKeyDown;
Expand Down Expand Up @@ -149,5 +150,10 @@ private void AddActionDialog_OnPrimaryButtonClick(ContentDialog sender, ContentD
var shortcutFunction = m_mapper.Map<ShortcutFunctionModel>(m_viewModel.AddShortcutFunctionModel);
m_shortcutKeyService.AddShortcutFunction(shortcutFunction);
}

private void ShortcutKeySettingPanel_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
m_viewModel.ControlWidth = e.NewSize.Width;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ public List<KeyValuePair<string,string>> Actions
}

public string AddShortcutFunctionTypeName { get; set; }

public double ControlWidth { get; set; }
}
}

0 comments on commit 567cc6b

Please sign in to comment.