Skip to content

Commit

Permalink
Fix sample presenter not properly determing if its empty (microsoft#1374
Browse files Browse the repository at this point in the history
)

<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
The sample presenter did not properly determine if it was empty
resulting in it not hiding despite it being empty.
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Fixes microsoft#1373
## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
marcelwgn committed Oct 17, 2023
1 parent b78b8a5 commit 220426e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions WinUIGallery/Controls/SampleCodePresenter.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public IList<ControlExampleSubstitution> Substitutions
set { SetValue(SubstitutionsProperty, value); }
}

public bool IsEmpty => Code.Length == 0 && CodeSourceFile == null;
public bool IsEmpty => string.IsNullOrEmpty(Code) && string.IsNullOrEmpty(CodeSourceFile);

private string actualCode = "";
private static Regex SubstitutionPattern = new Regex(@"\$\(([^\)]+)\)");
Expand All @@ -88,7 +88,7 @@ private static void OnDependencyPropertyChanged(DependencyObject target, Depende

private void ReevaluateVisibility()
{
if (Code.Length == 0 && CodeSourceFile == null)
if (IsEmpty)
{
Visibility = Visibility.Collapsed;
}
Expand Down

0 comments on commit 220426e

Please sign in to comment.