Skip to content

Commit

Permalink
remove explicit datatemplate, we are setting this globally in applica…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
tomlm committed Dec 14, 2024
1 parent a399f28 commit 4e902fb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/Consolonia.Core/Controls/ConsoloniaAccessText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public sealed class ConsoloniaAccessText : AccessText
{
private Run _accessRun;

static ConsoloniaAccessText()
{
AffectsRender<ConsoloniaAccessText>(ShowAccessKeyProperty);
}

public ConsoloniaAccessText()
{
this.PropertyChanged += OnPropertyChanged;

Check notice on line 22 in src/Consolonia.Core/Controls/ConsoloniaAccessText.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Controls/ConsoloniaAccessText.cs(22,13)
Expand Down
4 changes: 2 additions & 2 deletions src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public override void OnFrameworkInitializationCompleted()
{
// override AccessText to use ConsoloniaAccessText as default contentpresenter for unknown data types (aka string)
this.DataTemplates.Add(new FuncDataTemplate<object>(

Check notice on line 27 in src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs

View workflow job for this annotation

GitHub Actions / build

"[ArrangeThisQualifier] Qualifier 'this.' is redundant" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Infrastructure/ConsoloniaApplication.cs(27,13)
(data, s) =>
(data, _) =>
{
if (data != null && data is string str)
if (data != null && data is string)
{
var result = new ConsoloniaAccessText();
result.Bind(TextBlock.TextProperty,
Expand Down
7 changes: 0 additions & 7 deletions src/Consolonia.Themes/Templates/Controls/Menu.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
<ContentPresenter Name="PART_HeaderPresenter"
Content="{TemplateBinding Header}"
Margin="{TemplateBinding Padding}">
<ContentPresenter.DataTemplates>
<DataTemplate DataType="system:String">
<!-- ReSharper disable once Xaml.BindingWithContextNotResolved Just workaround - Its not binding, it's TemplateBinding-->
<core:ConsoloniaAccessText Text="{Binding}"
Foreground="{TemplateBinding (TemplatedControl.Foreground)}" />
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>
</helpers:CaretControl>
<Popup Name="PART_Popup"
Expand Down
5 changes: 0 additions & 5 deletions src/Consolonia.Themes/Templates/Controls/MenuItem.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Grid.Column="2">
<ContentPresenter.DataTemplates>
<DataTemplate DataType="sys:String">
<core:ConsoloniaAccessText Text="{Binding}" />
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>
<TextBlock x:Name="PART_InputGestureText"
Grid.Column="3"
Expand Down

0 comments on commit 4e902fb

Please sign in to comment.