示例#1
0
        private void ShowListItem(List <Item4Show> items)
        {
            DispatcherEx.xInovkeLowestPriority(() => {
                try
                {
                    tvMain.Items.Clear();
                    int no = 0;
                    foreach (var itShow in items.xSafeForEach())
                    {
                        no++;
                        var headerPnl         = new StackPanel();
                        headerPnl.Orientation = System.Windows.Controls.Orientation.Horizontal;

                        var noTxt     = new TextBlock();
                        noTxt.Text    = string.Format("{0}.", no);
                        noTxt.Padding = new Thickness(0, 5, 0.0, 0);
                        var leaf      = new CtlLeaf(itShow.Text.xRemoveLineBreak(" ").Trim(),
                                                    itShow.HighlightKey,
                                                    null, itShow.ImageName,
                                                    itShow.ActUseImage,
                                                    null);

                        headerPnl.Children.Add(noTxt);
                        headerPnl.Children.Add(leaf);

                        var it    = tvMain.xAppend(headerPnl, null);
                        it.Tag    = itShow.Tag;
                        it.Margin = ItemMargin;

                        it.MouseDoubleClick  += tvMain_MouseDoubleClick;
                        it.MouseLeftButtonUp += tvMain_MouseLeftButtonUp;
                    }
                }
                catch (Exception e)
                {
                    Log.Exception(e);
                }
            });
        }
示例#2
0
        public void AppendInpuTextForEndItem(string txt)
        {
            var item4Show = new Item4Show(txt, txt);
            var ctlLeaf   = new CtlLeaf(item4Show.Text.xRemoveLineBreak(" ").Trim(), item4Show.HighlightKey, null, item4Show.ImageName, item4Show.ActUseImage, null);
            var sp        = new StackPanel();

            sp.Orientation = System.Windows.Controls.Orientation.Horizontal;
            var noTxt = new TextBlock
            {
                Text = string.Format("{0}. ", tvMain.Items.Count + 1)
            };

            sp.Children.Add(noTxt);
            sp.Children.Add(ctlLeaf);
            ctlLeaf.Padding = new Thickness(0.0);
            var it = tvMain.xAppend(sp, null);

            it.Tag                = item4Show.Tag;
            it.Margin             = ItemMargin;
            it.MouseDoubleClick  += tvMain_MouseDoubleClick;
            it.MouseLeftButtonUp += tvMain_MouseLeftButtonUp;
        }