Skip to content

Commit

Permalink
Make DisplayMemberName obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrozsival committed Feb 27, 2024
1 parent 244d955 commit a9b60fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ DataTemplate DefaultTemplate

if (RuntimeFeature.IsShellSearchResultsRendererDisplayMemberNameSupported)
{
#pragma warning disable CS0618
label.SetBinding(Label.TextProperty, SearchHandler.DisplayMemberName ?? ".");
#pragma warning restore CS0618
}
else
{
#pragma warning disable CS0618
if (SearchHandler.DisplayMemberName is not null)
{
Application.Current?.FindMauiContext()?.CreateLogger<ShellSearchResultsRenderer>()?.LogError(TrimmerConstants.SearchHandlerDisplayMemberNameNotSupportedWarning);
throw new InvalidOperationException(TrimmerConstants.SearchHandlerDisplayMemberNameNotSupportedWarning);
}
#pragma warning restore CS0618

label.SetBinding(Label.TextProperty, TypedBinding.ForSingleNestingLevel(string.Empty, static (object o) => o));
}
Expand Down
3 changes: 3 additions & 0 deletions src/Controls/src/Core/Shell/SearchHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,11 @@ void ISearchHandlerController.QueryConfirmed()
BindableProperty.Create(nameof(Command), typeof(ICommand), typeof(SearchHandler), null, BindingMode.OneTime,
propertyChanged: OnCommandChanged);

#pragma warning disable CS0618
/// <summary>Bindable property for <see cref="DisplayMemberName"/>.</summary>
public static readonly BindableProperty DisplayMemberNameProperty =
BindableProperty.Create(nameof(DisplayMemberName), typeof(string), typeof(SearchHandler), null, BindingMode.OneTime);
#pragma warning restore CS0618

/// <summary>Bindable property for <see cref="IsSearchEnabled"/>.</summary>
public static readonly BindableProperty IsSearchEnabledProperty =
Expand Down Expand Up @@ -498,6 +500,7 @@ public object CommandParameter
}

/// <include file="../../../docs/Microsoft.Maui.Controls/SearchHandler.xml" path="//Member[@MemberName='DisplayMemberName']/Docs/*" />
[Obsolete("Use ItemTemplate instead.")]
public string DisplayMemberName
{
get { return (string)GetValue(DisplayMemberNameProperty); }
Expand Down

0 comments on commit a9b60fc

Please sign in to comment.