Search code examples
c#xamlprismrider

Rider Code Completion for Autowired ViewModel (Prism)


I'm working on a project that uses Prism for its client software. I have a UserControl XAML file that looks something like this:

<UserControl x:Class="UserModule.Frontend.UserListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
  <Grid>
    <ListView ItemsSource="{Binding Users}"/>
  </Grid>
</UserControl>

The actual XAML is a bit longer, but my question is:

Rider shows me a warning at the binding of the list view's ItemsSource property. I have a ViewModel that Prism injects correctly and I can see that the list has been populated. However, at design time, I can't see if the property exists, if I don't check for myself. At the same time, I get a warning in the ViewModel class, that the public getter of Users could be removed.

Is there a way to get code completion to recognize the autowired ViewModel with Prism?


Solution

  • You need to define the d:DataContext for your view. And while you're at it, vote for the feature...