Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would do this by switching the visibility of the datagrid off and the visibility of say a textblock on. You can do this with binding and a converter:</p> <p><strong>Converter:</strong></p> <pre><code>public class ObjectToVisibilityConverter : IValueConverter { public bool Negate { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (!Negate) { return (value == null) ? Visibility.Collapsed : Visibility.Visible; } else { return (value == null) ? Visibility.Visible : Visibility.Collapsed; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } </code></pre> <p>}</p> <p><strong>XAML:</strong></p> <pre><code> &lt;UserControl.Resources&gt; &lt;xmlnsref:ObjectToVisibilityConverter x:Key="ObjectToVisibilityConverter" /&gt; &lt;xmlnsref:ObjectToVisibilityConverter Negate="True" x:Key="ReversedObjectToVisibilityConverter" /&gt; &lt;/UserControl.Resources&gt; &lt;StackPanel&gt; &lt;data:dataGrid Visibility="{Binding MyDataSetObject, Converter={StaticResource ObjectToVisibilityConverter}}"&gt; ... /&gt; &lt;TextBlock Text="No results found." Visibility="{Binding MyDataSetObject, Converter={StaticResource ReversedObjectToVisibilityConverter}}"&gt; /&gt; &lt;/StackPanel&gt; </code></pre> <p>This will hide the grid (and show the textbox) if the MyDataSetObject object is null, and vica-versa if not null (Note the <strong>Negate</strong> property on the converter that will reverse the visibility)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload