예제 #1
0
        /// <summary>
        /// Here we launch the custom tag editor in a popup
        /// </summary>
        private void TradesGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            if ((string)e.Column.Header == "Tags")
            {
                //make sure the popup isn't too big, otherwise items can be hidden in small resolutions
                TagPickerPopup.Height = Math.Min(600, TradesGrid.ActualHeight - 100);

                //Fill it
                TagPickerPopupListBox.ItemsSource = Context
                                                    .Tags
                                                    .OrderBy(x => x.Name)
                                                    .ToList()
                                                    .Select(
                    x => new CheckListItem <Tag>(x))
                                                    .ToList();

                var trade = (Trade)TradesGrid.SelectedItem;

                if (trade.Tags != null)
                {
                    foreach (CheckListItem <Tag> item in TagPickerPopupListBox.Items)
                    {
                        item.IsChecked = trade.Tags.Contains(item.Item);
                    }
                }

                //and open it at the right position
                TagPickerPopup.PlacementTarget = TradesGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex);
                TagPickerPopup.IsOpen          = true;
            }
        }
예제 #2
0
        /// <summary>
        /// Here we launch the custom tag editor in a popup
        /// </summary>
        private void TradesGrid_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
        {
            if ((string)e.Column.Header == "Tags")
            {
                //Fill it
                TagPickerPopupListBox.ItemsSource = Context
                                                    .Tags
                                                    .OrderBy(x => x.Name)
                                                    .ToList()
                                                    .Select(
                    x => new CheckListItem <Tag>(x))
                                                    .ToList();

                var trade = (Trade)TradesGrid.SelectedItem;

                if (trade.Tags != null)
                {
                    foreach (CheckListItem <Tag> item in TagPickerPopupListBox.Items)
                    {
                        item.IsChecked = trade.Tags.Contains(item.Item);
                    }
                }

                //and open it at the right position
                TagPickerPopup.PlacementTarget = TradesGrid.GetCell(e.Row.GetIndex(), e.Column.DisplayIndex);
                TagPickerPopup.IsOpen          = true;
            }
        }