View Template Design Time ViewModel
The Prism Template Pack is fantastic, but I'm curious if others would agree that getting a design time viewmodel instance would be extremely handy to have in the View Template.
Only a few lines would need to be added:
<UserControl x:Class="AssemblyName.Views.View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:AssemblyName.ViewModels">
<d:UserControl.DataContext>
<vm:ViewModel />
</d:UserControl.DataContext>
<Grid>
</Grid>
</UserControl>
and in the a parameterless constructor for the ViewModel:
public ViewModel()
{
if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
// Initialize design time data
}
}
I'm sure there's other possible solutions, but this is what I've been using in my projects. I also realize that I can create my own template, but felt that it might be a good idea to promote this design time code in the template pack for others to get the same benefits.
Thanks for the suggestion. Could you please post this in the proper repo? Thanks>
https://github.com/PrismLibrary/Prism-Extensibility
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.