我有一个这样的课程:
class FontSize
{
List<int> fontSizeList = new List<int>(new int[] { 10, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90 });
public List<int> GetList()
{
return fontSizeList;
}
}
当我想在其他文件中调用它时,我用
调用该类AssetText.FontFamily fontFamily = new AssetText.FontFamily();
我可以从这段代码中获取值:
List<string> fontFamilyList = fontFamily.GetList();
到目前为止,没有例外。但是当我需要来自另一个人的东西时(AssetList.xaml.cs)
public partial class EditText : Window
{
AssetText.FontFamily fontFamily = new AssetText.FontFamily();
AssetText.FontSize fontSize = new AssetText.FontSize();
AssetText.FontStyle fontStyle = new AssetText.FontStyle();
AssetText.ScrollSpeed scrollSpeed = new AssetText.ScrollSpeed();
AssetText.ScrollDirection scrollDirection = new AssetText.ScrollDirection();
AssetList assetList = new AssetList();
public EditText()
{
InitializeComponent();
AssetListData selectedItem = assetList.getSelectedItem();
List<string> fontFamilyList = fontFamily.GetList();
List<int> fontSizeList = fontSize.GetList();
List<string> fontStyleList = fontStyle.GetList();
List<double> scrollSpeedList = scrollSpeed.GetList();
List<string> scrollDirectionList = scrollDirection.GetList();
//Values of ComboBoxes
fontFamily_ComboBox.ItemsSource = fontFamilyList;
fontSize_ComboBox.ItemsSource = fontSizeList;
fontStyle_ComboBox.ItemsSource = fontStyleList;
scrollSpeed_ComboBox.ItemsSource = scrollSpeedList;
scrollDirection_ComboBox.ItemsSource = scrollDirectionList;
fontFamily_ComboBox.SelectedValue = selectedItem.textFontFamily;
fontSize_ComboBox.SelectedValue = selectedItem.textFontSize;
fontStyle_ComboBox.SelectedValue = selectedItem.textFontStyle;
scrollSpeed_ComboBox.SelectedValue = selectedItem.textScrollSpeed;
scrollDirection_ComboBox.SelectedValue = selectedItem.textScrollDirection;
}
}
然后在FontSize
类中发生StackOverflow异常。我不知道这段代码会发生什么,有人可以解释一下吗?
编辑我尝试使用调试,调试器在本节中继续循环:
AssetText.FontFamily fontFamily = new AssetText.FontFamily();
AssetText.FontSize fontSize = new AssetText.FontSize();
AssetText.FontStyle fontStyle = new AssetText.FontStyle();
AssetText.ScrollSpeed scrollSpeed = new AssetText.ScrollSpeed();
AssetText.ScrollDirection scrollDirection = new AssetText.ScrollDirection();
AssetList assetList = new AssetList();
编辑2 我尝试将代码设置为@ cubicle-jockey建议,并在Break模式下调用Exception,打开一个新窗口并表示应用程序处于中断模式。这是我第一次得到错误的exp,我根本不知道
编辑3 正如@peter提到可能存在创建新EditText的东西,也许这是相关的。我在AssetList.xaml.cs
中有这个代码public void GridContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
MenuItem item = (e.OriginalSource as RadMenuItem).DataContext as MenuItem;
typeValue = ((AssetListData)AssetList_GridView.SelectedItem).assetType;
switch (item.Text)
{
case "Edit Asset":
if (typeValue == "abc")
{
editText.Show();
this.Close();
break;
}
else if (typeValue == "aaa")
{
editGraphic.Show();
this.Close();
break;
}
else if (typeValue == "bbb")
{
editVideo.Show();
this.Close();
break;
}
else if (typeValue == "xxx")
{
editLiveVideo.Show();
this.Close();
break;
}
break;
case "Delete Asset":
this.AssetList_GridView.Items.Remove(this.AssetList_GridView.SelectedItem);
break;
}
}
答案 0 :(得分:0)
解决
我有:
EditText editText = new EditText();
在我的AssetList.xaml.cs中的部分类中,当我在EditText.xaml.cs中调用AssetList
时导致循环所以我将它移动到需要它的方法。
感谢大家的帮助!