Hello everyone!
I've run across a seemingly unsolvable problem.
I have created two different UserControls.
The first one has one TextBlock and one TextBox
(name: ValueBoxControl)
The second one is exactly like the first one, except that I've added a ListView to it.
(name: ListViewControl)
Now I have added the ValueBoxControl 6x to the ListViewControl (into the ListView).
This is all code-behind. I don't use XAML for this.
Okay, so far there are 6 Items in my ListView of the ListViewControl. These Items are all ValueBoxControls.
After an Item gets the Focus, I want to switch the values of the ValueBoxControl TextBox / TextBlock with the TextBox / TextBlock of the ListViewControl.
To achieve that I have to read the content of the ValueBoxControl, INSIDE the currently selected Item of the ListView.
So, my question is: How do I do that? Is there something like a List.SelectedItem.Content.Text? Of course not, but how do I do that? I am absolutely desperate and there's not a single solution on the whole World Wide Web.
private void SelectItem()
{
string clipContent;
string clipTitle;
string itemContent;
string itemTitle;
ValueBoxControl control = List.SelectedItem;
clipContent = ValueTextBox.Text;
clipTitle = TitleText.Text;
itemContent = control.Text;
itemTitle = control.TitleText.Text;
control.Text = clipContent;
control.TitleText.Text = clipTitle;
Text = itemContent;
TitleText.Text = itemTitle;
}
This code obviously won't work, but that's about the idea I have. The problem is that List.SelectItem returns an object type, while ValueBoxControl is a UserControl.
Greetings
Narakuvera