I have this table:
I use in my project this view Called NewItem and in this view there is two combobox.
I would like to do this : that in the combobox Group there are all DESCRIPTION of table GROUP, and when i choose an item of this description (of first combobox) the second combobox fills of descriptions relating only to that description that I have chosen before.
This is some code:
XAML NewItemView:
<ComboBox Height="21" HorizontalAlignment="Left" Margin="89,99,0,0"
VerticalAlignment="Top" Width="106" x:Name="Group" SelectedItem="{Binding SelectedGroup}" />
The ViewModel code is like:
[Export(typeof(IScreen))]
public class NewItemViewModel : Screen
{
public string SelectedGroup { get; set; }
public String[] Group { get { return Groups; } }
[..]
//Constructor
public NewArticleViewModel()
{
Groups = GetGroups();
}
//Method
private string[] GetGroups()
{
OleDbConnection conn = new OleDbConnection(StringConn);
List<Group> groups = new List<Group>();
conn.Open();
groups = conn.Query<Group>(Q_SELECT_GROUPS,null,null).ToList();
conn.Close();
string[] array = new string[groups.Count];
for (int i = 0; i < array.Length; i++)
{
array[i] = groups[i].Descripion;
}
return array;
}
}
GROUP CLASS IS :
public class Group
{
public int Id { get; set; }
public string Descripion { get; set; }
}
I wanted to specify that i use Caliburn.Micro and Dapper for acces'query.
Thank you so much !