Silverlight DataGrid ListBox example

Source: Internet
Author: User

<Usercontrol xmlns: My = "CLR-namespace: system. Windows. controls; Assembly = system. Windows. Controls. Data" X: class = "controltest. Page"
Xmlns = "http://schemas.microsoft.com/client/2007"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Width = "800" Height = "600" loaded = "usercontrol_loaded">
<Grid X: Name = "layoutroot" background = "black">
<Canvas X: Name = "dgcas" canvas. Top = "0" canvas. Left = "200">
<My: DataGrid X: Name = "mydg" gridlinesvisibility = "NONE" headersvisibility = "NONE" width = "400" Height = "300">
<My: DataGrid. Columns>
<! -- <My: Maid = "" width = "20"> </My: Maid> -->
<My: Maid = "{binding commentid}" width = "20"> </My: Maid>
<My: Maid = "{binding commentcontent}" width = "200"> </My: Maid>
<My: Maid = "{binding postpeople}" width = "80"> </My: Maid>
<! -- <My: Maid = "{binding posttime}" width = "80"> </My: Maid> -->
<My: Maid width = "80">
<My: datagridtemplatecolumn. celltemplate>
<Datatemplate>
<Textblock text = "{binding posttime}" fontfamily = "trebuchet ms" fontsize = "11" margin = "5, 4, 5, 4"/> </datatemplate>
</My: datagridtemplatecolumn. celltemplate>
<My: datagridtemplatecolumn. celleditingtemplate>
<Datatemplate>
<Datepicker selecteddate = "{binding posttime, mode = twoway}" selecteddateformat = "short"/>
</Datatemplate>
</My: datagridtemplatecolumn. celleditingtemplate>
</My: datagridtemplatecolumn>

<My: Maid = "{binding postip}" visibility = "Collapsed"> </My: Maid>
</My: DataGrid. Columns>
</My: DataGrid>
</Canvas>
<Canvas X: Name = "listcas" canvas. Top = "0" canvas. Left = "200">
<ListBox X: Name = "mylist" canvas. Top = "300" width = "400" Height = "300">
<ListBox. itemtemplate>
<Datatemplate>

<Stackpanel orientation = "vertical">
<Stackpanel style = "{staticresource floorpanel}">
<Textblock text = "{binding commentid}" horizontalalignment = "Left" fontsize = "12" foreground = "red"> </textblock>
<Textblock text = "{binding postpeople}" horizontalalignment = "Left" fontsize = "12" textwrapping = "Wrap" maxwidth = "80" fontweight = "bold" width = "100"> </textblock>
<Textblock text = "{binding posttime}" horizontalalignment = "Left" fontsize = "12" textwrapping = "Wrap" maxwidth = "80" fontweight = "semibold"> </textblock>
</Stackpanel>
<Textblock text = "{binding commentcontent}" textwrapping = "Wrap" maxwidth = "300" fontsize = "12" horizontalalignment = "Left"> </textblock>
</Stackpanel>

</Datatemplate>
</ListBox. itemtemplate>

</ListBox>

</Canvas>
</GRID>
</Usercontrol>

Mydg. itemssource = "helloworld". Split ();
List <comment> lst = new list <comment> ();
For (INT I = 1; I <10; I ++)
{
Lst. Add (New Comment ()
{
Commentid = I,
Commentcontent = "There must be a flexible monetary policy system to cope with the subprime mortgage crisis. After the subprime mortgage crisis, some countries experienced liquidity tightening. This "liquidity shortage" is the representation or essence and needs to be discussed. ",
Postpeople = "Zhou Xiaochuan ",
Posttime = datetime. Now. tolongtimestring (),
Postip = "127.0.0.1"
});
}
// Mydg. itemssource = lst;

Mylist. itemssource = lst;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.