public KnowItemDialog(Guid?id) { this.id = id; tags = new ObservableCollection <string>(); actionTypes = new ObservableCollection <vNextBot.Model.Action>(); using (ApplicationContext db = new ApplicationContext()) { allTags = db.GetTags(); foreach (string tag in allTags) { tags.Add(tag); } foreach (vNextBot.Model.Action item in db.Actions) { actionTypes.Add(item); } } InitializeComponent(); Type.ItemsSource = actionTypes; Tags.ItemsSource = tags; if (id.HasValue) { using (ApplicationContext db = new ApplicationContext()) { KnowledgeBase item = db.KnowledgeBases.Find(id); Question.Text = item.c_question; Tags.Text = item.GetTags(); Type.SelectedValue = actionTypes.First(t => t.id == item.f_action); Url.Text = item.GetUrl(); Title.Text = item.GetTitle(); IsDisabled.IsChecked = item.b_disabled; Date.Text = item.GetDate(); Weight.Text = item.c_weight.ToString(); } } else { Type.SelectedValue = actionTypes.First(t => t.c_const == "TEXT"); Weight.Text = "D"; } }