No datatype in datatemplate in Windows Phone (-)

Source: Internet
Author: User

I used to get used to WPF/SL. Now I have studied Windows Phone for a while and found that many restrictions have been imposed on Windows Phone sdks. Some methods of WPF/SL have been deleted.

The datatemplate was used in the Windows Phone project today to modify the items style of ListBox. However, during the test, the datatemplate was suddenly found to have no datatype attribute.

As follows:

<phone:PhoneApplicationPage.Resources>        <DataTemplate x:Key="listDataTemplate">            <StackPanel Orientation="Horizontal">                <TextBlock Text="{Binding UserID}" />                <TextBlock Text="  Name: "/>                <TextBlock Text="{Binding UserName}" />            </StackPanel>        </DataTemplate></phone:PhoneApplicationPage.Resources>

You can use <datatemplate X: Key = "listdatatemplate">,

<Datatemplate datatype = "{X: type local: userlist}"> but it cannot be used. It was completely OK in WPF before. Is this removed from Windows Phone?

Check msdn and Baidu. In Windows Phone, The ememplate does not seem to have the datatype attribute, but there is no detailed description, so, Google... (Google was too powerful to be attacked by the wall in tianchao, many webpages could not be opened, and the speed was too slow, so they could not read ...)

Finally, I found some articles in English. For the sake of performance and platform, Windows Phone may remove the datatype attribute. What's more, the trigger in datatemplate is not supported.

I personally think that datatype and trigger are very easy to bind to itemcontrol, and may cause performance loss. But is it really worthwhile to remove such a convenient method for some losses?

Occasionally, it is okay to bind several controls with the key value to the datatemplate, but if it is a large number of controls, this is very cumbersome.

OK. What is the difference between Windows Phone and WPF? Let's look at the code. See no datatype in datatemplate in Windows Phone (2)

<phone:PhoneApplicationPage.Resources>        <DataTemplate DataType="{x:Type local:UserList}">            <StackPanel Orientation="Horizontal">                <TextBlock Text="{Binding UserID}" />                <TextBlock Text="  Name: "/>                <TextBlock Text="{Binding UserName}" />            </StackPanel>        </DataTemplate></phone:PhoneApplicationPage.Resources>
Related Article

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.