C
C#•12mo ago
Suchacoolguy

Avalonia: how to get the data of a control where the sender belongs to?

My program requires a drag-and-drop. when i move a 'part' rectangle into another 'raw material' rectangle, it's successfully added to where i dropped but i need to remove the moved part from its original location. but i am struggling to get the data of the raw material where the dragged part belonged to... i guess it's because part rectangle is not directly parented with the raw material rectangle but i have no idea how to solve this 😦 The data structure of Bound ItemsSource: A list of RawMaterial ('ArrangedRawMaterials' in the code) RawMaterial contains a list of Parts ('PartsInside' in the code)
No description
No description
7 Replies
Buddy
Buddy•12mo ago
And modify the style accordingly Assuming you use Avalonia My apologies, just assumed you wanted to change style. Didn't read the question.
Suchacoolguy
SuchacoolguyOP•12mo ago
Yes i am using Avalonia. but i don't understand what you mean by set a class. you mean oh okay. that's fine
Suchacoolguy
SuchacoolguyOP•12mo ago
this is how it looks now (for your better understanding)
No description
Buddy
Buddy•12mo ago
Avalonia has classes, just like with web elements.
<div class="foo">

</div>
<div class="foo">

</div>
example What exactly isn't working?
Suchacoolguy
SuchacoolguyOP•12mo ago
yes, and i need to select the grey rectangle class which the orange rectangle belonged to. but when i try, the rawMaterial variable in the event handler image always gets null...
Buddy
Buddy•12mo ago
Did you set a breakpoint to see the values?
Suchacoolguy
SuchacoolguyOP•12mo ago
it's always null so i tried getting parent class without specifying the type. and it gets the border class which is the parent class right above it. but it doesn't get the grey rectangle when i specify the type Or name of it

Did you find this page helpful?