An error occurs when specifying a resource with the ViewModel of my class:
<Window x:Class="KTM.TouristsListWnd" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:KTM" mc:Ignorable="d" Title="TouristsList" Height="388.102" Width="1001.393" Loaded="Window_Loaded"> <Window.DataContext> <!-- ошибка воникает здесь --> <local:TouristsListViewModel /> </Window.DataContext> despite the fact that the class is in scope (public)?
public class TouristsListViewModel UPD: class constructor:
public TouristsListViewModel() { try { conn.Open(); MySqlCommand cmd = new MySqlCommand("SELECT * FROM tourmanager.tourists;", conn); MySqlDataAdapter adp = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); adp.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { _tourists.Add(new Tourist((int)dr["id"], (string)dr["firstname"], (string)dr["secondname"], (string)dr["patronymic"], (string)dr["passport"], (string)dr["sex"])); } } catch (MySqlException ex) { throw new Exception("", ex); } finally { conn.Close(); } }