What’s wrong with this WP7 Code ?

Here’s a sample code that i was trying for databinding the AutoCompleteBox in Windows Phone 7 .

What’s wrong with this WP7 Code ?

I was trying to bind a custom object to the AutoCompleteBox and ended up looking at the code for nearly 30 mins to figure out why the suggestion was not displaying . It was a simple fix though …

Try finding out the error in the code .

public partial class MainPage : PhoneApplicationPage

{

// Constructor

public MainPage()

{

InitializeComponent();

}

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)

{

List<Movie> Lst = new List<Movie>();

Lst.Add(new Movie { Name = "Velayutham", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Nanban", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Yohan", Actor = "Vijay" });

Lst.Add(new Movie { Name = "Billa 2", Actor = "Ajith" });

Lst.Add(new Movie { Name = "Maatran", Actor = "Surya" });

autoCompleteBox1.ItemsSource = Lst;

}

}

class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

The above code worked fine when i modified the line 21 from

class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

to

public class Movie

{

public string Name { get; set; }

public string Actor { get; set; }

}

Just a introduction of the keyword public solved the problem 🙂

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

In this post, you’ll learn about the Win32 Error “0x000019E5 – ERROR_COULD_NOT_RESIZE_LOG” that you get when debugging system erors in...
In this post, you’ll learn about the error “CO_E_DBERROR 0x8004E02B” that is returned when working with COM based APIs or...
In this post, you’ll learn about the Win32 Error “0x000019D0 – ERROR_LOG_BLOCK_VERSION” that you get when debugging system erors in...