Где проблема? < /p>
Код: Выделить всё
public MainWindow()
{
InitializeComponent();
DataContext = this;
HoleTreeViewDaten();
LVAnzahlInt32 = MyAktTVList.Count;
MenuItem root = new MenuItem();
MenuItem childItem1 = new MenuItem();
MenuItem childItem2 = new MenuItem();
MenuItem childItem3 = new MenuItem();
var item = new TreeViewItem();
root = new MenuItem() { Text = TreeViewErsterEintrag, ImageSource = TreeViewErsterIcon };
int ix = 0;
int i1 = 0;
while (i1 < LVAnzahlInt32)
{
if (MyAktTVList[i1].Position == "1")
{
childItem1 = new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon };
root.Items.Add(childItem1);
MyTreeView003.Items.Add(childItem1);
}
if (MyAktTVList[i1].Position == "2")
{
childItem2 = new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon };
root.Items.Add(childItem2);
var subItem = new TreeViewItem();
MyTreeView003.Items.Add(childItem2);
}
if (MyAktTVList[i1].Position == "3")
{
childItem3 = new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon };
root.Items.Add(childItem3);
var subItem = new TreeViewItem();
MyTreeView003.Items.Add(childItem3);
}
i1++;
}
}
Я обнаружил много примеров, но в созвездии с:
lin /> Текст
, к сожалению, ничего, как субтом < /li>
< /ul>
Я изменяю код на: < /p>
Код: Выделить всё
if (MyAktTVList[i1].Position == "1")
{
childItem1 = new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon };
root.Items.Add(childItem1);
}
if (MyAktTVList[i1].Position == "2")
{
childItem1.Items.Add( new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon });
}
if (MyAktTVList[i1].Position == "3")
{
childItem2.Items.Add(new MenuItem() { Text = MyAktTVList[i1].Bezeichnung, ImageSource = "Images/" + MyAktTVList[i1].MenueIcon });
childItem1.Items.Add(childItem2);
}
>
Подробнее здесь: https://stackoverflow.com/questions/797 ... dd-subitem
Мобильная версия