/ src / modules / cmdpal / Microsoft.CmdPal.UI / Controls / IconMarginConverter.cs
IconMarginConverter.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using Microsoft.UI.Xaml;
 6  using Microsoft.UI.Xaml.Data;
 7  
 8  namespace Microsoft.CmdPal.UI.Controls;
 9  
10  public sealed partial class IconMarginConverter : IValueConverter
11  {
12      public object Convert(object value, Type targetType, object parameter, string language)
13      {
14          // Only include a margin if there is text to separate from the icon.
15          var text = value as string;
16          return string.IsNullOrEmpty(text) ? new Thickness(0) : new Thickness(0, 0, 4, 0);
17      }
18  
19      public object ConvertBack(object value, Type targetType, object parameter, string language) => throw new NotImplementedException();
20  }