Page 1 of 1

The ListBox can not display the "name" attribute

Posted: Wed Jan 11, 2017 10:26 am
by tomny
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;
            }
        }
           
    }
}


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

Posted: Wed Jan 11, 2017 10:31 am
by tomny
The emulator is displayed correctly:
Image001.png
Image001.png (3.83 KiB) Viewed 8619 times


The browser can not display:
Image002.png
Image002.png (7.22 KiB) Viewed 8619 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. :(

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

Posted: Wed Jan 11, 2017 10:45 am
by JS-Support @Userware
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

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

Posted: Wed Jan 11, 2017 10:58 am
by tomny
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

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

Posted: Fri Jan 13, 2017 6:07 am
by JS-Support @Userware
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