Note that there are some explanatory texts on larger screens.

plurals
  1. POShow “No record found” message on a WPF DataGrid when it's empty
    primarykey
    data
    text
    <p>I'm trying to display a "No record found" Message in my WPF Datagrid</p> <p>I tried the solution from the same question here: <a href="https://stackoverflow.com/questions/4687414/show-no-record-found-message-on-a-wpf-datagrid-when-its-empty">Show &quot;No record found&quot; message on a WPF DataGrid when it&#39;s empty</a></p> <p>But so far I didn't find a way to add a empty line only when my ObservableCollection is empty. This is the code for my datagrid:</p> <pre><code> &lt;DataGrid DataContext="{Binding RelativeSource={RelativeSource AncestorType=Window}}" ItemsSource="{Binding CameraListObjCode}" AutoGenerateColumns="False" Height="145" HorizontalAlignment="Left" Margin="62,105,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="361" IsReadOnly="True"&gt; &lt;DataGrid.Resources&gt; &lt;conv:IntIsEqualOrGreaterThan x:Key="intIsEqualOrGreaterThan"/&gt; &lt;conv:IntIsLessThan x:Key="intIsLessThan"/&gt; &lt;Style TargetType="DataGrid"&gt; &lt;Setter Property="RowDetailsVisibilityMode" Value="Collapsed"&gt;&lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;!--&lt;DataTrigger Binding="{Binding Path=CameraListObjCode.Count, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource intIsEqualOrGreaterThan}, ConverterParameter=1}" Value="True"&gt;--&gt; &lt;DataTrigger Binding="{Binding Path=CameraListObjCode.Count, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource intIsLessThan}, ConverterParameter=1}" Value="True"&gt; &lt;Setter Property="RowHeight" Value="0"&gt;&lt;/Setter&gt; &lt;Setter Property="RowDetailsVisibilityMode" Value="Visible"&gt;&lt;/Setter&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/DataGrid.Resources&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="Camera Model:" Binding="{Binding CameraModel}" /&gt; &lt;DataGridTextColumn Header="Serial Nr:" Binding="{Binding SerialNr}" /&gt; &lt;DataGridTextColumn Header="IP Address:" Binding="{Binding IPAddress}" /&gt; &lt;/DataGrid.Columns&gt; &lt;DataGrid.RowDetailsTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel&gt; &lt;TextBlock Text="No Record Found" Visibility="Visible" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/DataGrid.RowDetailsTemplate&gt; &lt;/DataGrid&gt; </code></pre> <p>The Triggers all work as as expected. But the message is not displayed. When I change the Trigger Converter from "intIsLessThan" to "intIsEqualOrGreaterThan" the Message is shown instead of the actual datagrid entry.</p> <p>So I guess just the empty default row is missing. But how can I add an empty default row?</p> <p>I hope anyone can help me with this problem. I'm already searching for two days now to find a solution...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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