English 中文(简体)
以儿童因素为依据的等级划分?
原标题:sort stackpanel based on child elements?
  • 时间:2012-04-17 10:17:29
  •  标签:
  • c#
  • wpf
  • linq

是否有办法根据某些儿童要素命令打脚石?

在我后面的《守则》中,增加了一些通用的东西,如团体箱和文字锁等,而文字信息是我的网络服务时间,我尝试用林克通过排位顺序进行分类,但产出仍然不变。

因此,我很想知道,它是否有可能用一种打脚轻的儿童因素,即文字锁。 规定日期归属的案文?

        XDocument xDoc = XDocument.Load(uriGroups);
        var sortedXdoc = xDoc.Descendants("Student")
                       .OrderByDescending(x => Convert.ToDateTime(x.Element("TimeAdded").Value));


        foreach (var node in xDoc.Descendants("Student"))
        {

            GroupBox groupbox = new GroupBox();
            groupbox.Header = String.Format(node.Element("StudentID").Value);
            groupbox.Width = 100;
            groupbox.Height = 100;
            groupbox.Margin = new Thickness(1);

            TextBlock textBlock = new TextBlock();
            textBlock.Text = String.Format(node.Element("FirstName").Value + " " + (node.Element("LastName").Value));
            textBlock.TextAlignment = TextAlignment.Center;

            TextBlock textBlock1 = new TextBlock();
            textBlock1.Text = (DateTime.Parse(node.Element("TimeAdded").Value)).ToString("d");
            String.Format("{0:d/M/yyyy}", DateTime.Parse(node.Element("TimeAdded").Value));
            textBlock1.TextAlignment = TextAlignment.Center;
            textBlock1.VerticalAlignment = VerticalAlignment.Bottom;

            StackPanel stackPanel = new StackPanel();
            stackPanel.Children.Add(groupbox);

            stackPanel.Children.Add(textBlock);
            stackPanel.Children.Add(textBlock1);
            stackPanel.Margin = new Thickness(5);
            stackPanel.MouseEnter += new MouseEventHandler(stackpanel_MouseEnter);
            stackPanel.MouseLeave += new MouseEventHandler(stackpanel_MouseLeave);
            MainArea1.Children.Add(stackPanel);
        }
    }
最佳回答

The order of display is totally defined by the order of calls to

MainArea1.Children.Add(stackPanel);

So, try something like

 foreach (var node in xDoc.Descendants("Student").OrderBy(e => ...))
 {
    ....
 }

(你真的应该在这里使用Temlates)

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签