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

This blog post will guide you through several effective methods to troubleshoot and resolve the issue of Microsoft Edge not...
Windows 11 offers a range of audio enhancements that can enrich your listening experience. These enhancements include features like virtual...
Windows 11 brings a fresh and visually stunning design to your desktop, and one of the standout features is the...