C
C#4w ago
Robisca

WPF running .ToString() of viewmodel instead of showing the coresponding view

For the context, the app is implementing mvvm and i have: a viewmodel named CheckViewModel and a corresponding view, some base classes like BaseViewModel, ObservableObject,etc and navigation through a interface and a class that implements that interface My problem rises when I run the app. I Expect to get the view for CheckViewModel, which have some UI elements there but instead i get on top left corner the .ToString() method from CheckViewModel. In the App.xaml i also have a defined resource for that view App.xaml:
<Application x:Class="WPF_UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewmodel="clr-namespace:WPF_UI.ViewModel"
xmlns:view="clr-namespace:WPF_UI.View">
<Application.Resources>
<DataTemplate DataType="{x:Type viewmodel:CheckViewModel}">
<view:CheckView />
</DataTemplate>
</Application.Resources>
</Application>
<Application x:Class="WPF_UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:viewmodel="clr-namespace:WPF_UI.ViewModel"
xmlns:view="clr-namespace:WPF_UI.View">
<Application.Resources>
<DataTemplate DataType="{x:Type viewmodel:CheckViewModel}">
<view:CheckView />
</DataTemplate>
</Application.Resources>
</Application>
No description
2 Replies
ACiDCA7
ACiDCA74w ago
Stack Overflow
datatemplate in app.xaml is not getting picked up without any styles?
I have a DataTemplate in app.xaml that binds a view to a viewmodel. <Application.Resources> <DataTemplate DataType="{x:Type vm:someviewmodeltype}"> <vw:somevwcontrol /&g...
Robisca
RobiscaOP4w ago
Wow, I didn't expect that. Now it works perfectly! Thanks!
Want results from more Discord servers?
Add your server