Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Why does this raise a Parse exception in XAML?

$
0
0

I suppose I am a beginner in C#, and I'm decently familiar with creating basic Windows forms projects. However, when it comes to XAML and using WPF, I'm just a tick above clueless. In the Form constructor of a windows forms app, the following for loop would not throw an exception.

 for (int i = 0; i < Game_Moderator.Return_Combo_Box_Items().Length; i++)
            {
                Card_Selection.Items.Add(Game_Moderator.Return_Combo_Box_Items()[i]);
            }

However, in XAML's  MainWindow() method, I receive the following exception: 

"A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll. Additional information: 'The invocation of the constructor on type 'Go_Fish_WPF.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'."

Yet, when I add each item individually via the add method:

Card_Selection.Items.Add("Ace");

Card_Selection.Items.Add("Two");

...

Card_Selection.Items.Add("King");

There are no exceptions. Why does the for loop cause an Exception? By the way, Card_Selection is a combobox.

Also, Game_Moderator.Return_Combo_Box_Items() is perfectly functional.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>