The ListBox can not display the "name" attribute

Please report bugs here. If you are unsure whether something is a bug or an expected behavior, please post it on the "Technical Support" forum instead, and wait for a moderator to handle/move the post.
tomny
Posts: 37
Joined: Sat Nov 19, 2016 7:23 pm

The ListBox can not display the "name" attribute

Postby tomny » Wed Jan 11, 2017 10:26 am

Dear JS-Support,

We found a strange problem in the course of the project. When a class's property name is "name", the ListBox, DataGrid can not display it in the browser, either using DisplayMemberPath or using a DataTemplate.

the MainPage.xaml :

Code: Select all

<Page
    x:Class="bugforname.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:bugforname"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid>
        <ListBox Width="300"
                 x:Name="listBox1"
                 DisplayMemberPath="name"
                 SelectedValuePath="id"
                 Background="yellow" 
                 HorizontalAlignment="Left"
                 >
        </ListBox>
    </Grid>
</Page>
the MainPage.xaml.cs:


Code: Select all

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace bugforname
{
    public partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            // Enter construction logic here...

            this.Loaded += MainPage_Loaded;
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            List<TestBug> buglist = new List<bugforname.TestBug>()
            {
                 new TestBug()
                 {
                     id=1, name="Text111"

                 },
                  new TestBug()
                 {
                       id=2, name="Text222"
                 },
                   new TestBug()
                 {
                         id=3, name="Text333"
                 },

            };


            listBox1.ItemsSource = buglist;


           // throw new NotImplementedException();
        }
    }

    public class TestBug
    {
        public int id
        {
            get;
            set;
        }

        public string name
        {
            get;
            set;
        }

        public string showname
        {
            get
            {
                return name;
            }
        }
           
    }
}


tomny
Posts: 37
Joined: Sat Nov 19, 2016 7:23 pm

Re: The ListBox can not display the "name" attribute

Postby tomny » Wed Jan 11, 2017 10:31 am

The emulator is displayed correctly:
Image001.png
Image001.png (3.83 KiB) Viewed 518 times


The browser can not display:
Image002.png
Image002.png (7.22 KiB) Viewed 518 times


When I need to show the properties for: showname, the browser works.

PS: In order to find out the problem, we wasted a lot of time. :(

JS-Support
Site Admin
Posts: 740
Joined: Tue Apr 08, 2014 3:42 pm

Re: The ListBox can not display the "name" attribute

Postby JS-Support » Wed Jan 11, 2017 10:45 am

Hi tomny,

Thanks for your message.

This issue is indeed very strange.

Thank you for managing to isolate the problem.

We are going to fix it asap.

tomny wrote:PS: In order to find out the problem, we wasted a lot of time. :(

We really appreciate your valuable help during this Beta period. Thanks so much.

Regards,
JS-Support

tomny
Posts: 37
Joined: Sat Nov 19, 2016 7:23 pm

Re: The ListBox can not display the "name" attribute

Postby tomny » Wed Jan 11, 2017 10:58 am

Hi JS-Support:
Thank you for your prompt reply.
This problem is also related to another problem: when using jQueryAjaxHelper serialization, if the property name has "name" in the browser, it can not be serialized.

Regards,
Tomny

JS-Support
Site Admin
Posts: 740
Joined: Tue Apr 08, 2014 3:42 pm

Re: The ListBox can not display the "name" attribute

Postby JS-Support » Fri Jan 13, 2017 6:07 am

tomny wrote:This problem is also related to another problem: when using jQueryAjaxHelper serialization, if the property name has "name" in the browser, it can not be serialized.


Thanks. Ok, we are going to fix this as well.

JS-Support


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest

 

 

cron