This is my class:
public class MenuMaker
{
public MenuMaker()
{
NumbersOfItems = 5;
MenuList = new ObservableCollection<string>();
UpdateMenu();
}
public int NumbersOfItems { get; set; }
ObservableCollection<string> MenuList { get; private set; }
public string GeneratedData { get; private set; }
string[] firthMill = new string[] { "Red Borshc ", "Green Borshc ", "Soup " };
string[] secondMill = new string[] { "with salat ", "with porrage " };
string[] drink = new string[] { "and tee", "and coffee", "and juce", "and vodka" };
public void UpdateMenu()
{
MenuList.Clear();
Random random = new Random();
string newMill;
for (int i = 0; i < NumbersOfItems; i++)
{
newMill = "";
newMill += firthMill[random.Next(firthMill.Length)] + secondMill[random.Next(secondMill.Length)] +
drink[random.Next(drink.Length)];
MenuList.Add(newMill);
}
DateTime nowIs = DateTime.Now;
GeneratedData = "This menu was generated on " + nowIs.ToString();
}
}
and here I want to add it to the resources:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:MenuMaker x:Key="menu"/>
</Window.Resources>
</Window>
but have a problem:
the type "MenuMaker" does not include any accessible constructors
I searched a lot, but does not find correct answer for my case. I can not understand: in my MenuMaker class I use parameterless constructor, but it still doesn't work. Can somebody help me?