Ejemplo n.º 1
0
 private void SearchText_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Up)
     {
         if (SourceListBox != null && SourceListBox.ItemsSource != null && popup.IsOpen)
         {
             if (SourceListBox.SelectedIndex > 0)
             {
                 SourceListBox.SelectedIndex--;
                 e.Handled = true;
                 SourceListBox.ScrollIntoView(SourceListBox.SelectedItem);
             }
         }
     }
     else if (e.Key == Key.Down)
     {
         if (SourceListBox != null && SourceListBox.ItemsSource != null && popup.IsOpen)
         {
             if (SourceListBox.SelectedIndex < SourceListBox.Items.Count)
             {
                 SourceListBox.SelectedIndex++;
                 e.Handled = true;
                 SourceListBox.ScrollIntoView(SourceListBox.SelectedItem);
             }
         }
     }
     else if (e.Key == Key.Enter)
     {
         if (SourceListBox != null && SourceListBox.ItemsSource != null && SourceListBox.SelectedItem != null &&
             SourceListBox.SelectedIndex >= 0 && popup.IsOpen)
         {
             if (this.SelectedItem != SourceListBox.SelectedItem)
             {
                 this.SelectedItem = SourceListBox.SelectedItem;
             }
             else
             {
                 string newvalue = "";
                 if (_property != null)
                 {
                     newvalue = _property.GetValue(SourceListBox.SelectedItem, null).ToString();
                 }
                 else
                 {
                     newvalue = SourceListBox.SelectedItem.ToString();
                 }
                 if (!SearchText.Text.Equals(newvalue))
                 {
                     _insertText           = true;
                     SearchText.Text       = newvalue;
                     SearchText.CaretIndex = SearchText.Text.Length;
                 }
             }
             popup.IsOpen = false;
         }
         else
         {
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the source module data.
        /// </summary>
        private void LoadSourceModuleData()
        {
            //check to be sure that a source instance has been selected before proceeding.
            //this can cause errors if not checked for!
            if (SourceInstance.SelectedIndex > -1)
            {
                int SourceModID  = Int32.Parse(SourceInstance.SelectedItem.Value);
                int ModuleTypeID = Int32.Parse(ModuleTypes.SelectedItem.Value);

                ContentManagerDB contentDB = new ContentManagerDB();
                SourceListBox.DataValueField = "ItemID";
                SourceListBox.DataTextField  = "ItemDesc";
                SourceListBox.DataSource     = contentDB.GetSourceModuleData(ModuleTypeID, SourceModID);
                SourceListBox.DataBind();
            }
        }