1
votes

I have a custom view which shows a "No Results" message when a page has no values.

 <common:NoResults 
    IsVisible="{Binding Details, 
    Converter={ StaticResource EmptyListIsTrueConverter }}"></common:NoResults>

The problem is when the page is loading, there are no values so it shows and should not.

Is there a way to combine a check for an empty list and another Model property like IsBusy into one Converter ?

2
I would add one property IsPageReady then ShowHide the content inside the page itself. When the Page is ready, then display the content . - Nirmal Subedi

2 Answers

1
votes

In IsVisible set the binding to a property DoneLoadingAndNoValues in the viewmodel with default value false.

Set this property to true when loading is done and Details contains no values.

ViewModel (implements INotifyPropertyChanged with OnPropertyChanged):

private bool doneLoadingAndNoValues = false; // default is false

public bool DoneLoadingAndNoValues
{
    get { return doneLoadingAndNoValues; }
    set
    {
        doneLoadingAndNoValues= value;
        OnPropertyChanged(nameof(DoneLoadingAndNoValues));
    }
}
...
// Done loading and Details contains no values:
DoneLoadingAndNoValues = true;

XAML:

<common:NoResults IsVisible="{Binding DoneLoadingAndNoValues}" />
0
votes

I can't see a way to easily do this in XAML. Try it in your code behind.

When the page is finished loading, execute a function which checks the how many values there are. If there are no values, show your no values message.