AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.88k stars 2.24k forks source link

Editing contents of a <TabItem> causes the designer to swap back to the first <TabItem> #4671

Open derekantrican opened 4 years ago

derekantrican commented 4 years ago

Normally in WPF (I believe) when editing the XAML contents of a <TabItem> the designer will switch to that tab so you can see the controls you are adding. I can also switch to this tab by clicking on it in the designer.

In Avalonia, I can click on the tab in the designer but the moment I start modifying the XAML contents of that tab, the designer swaps back to the first tab.

kekekeks commented 4 years ago

@ForNeVeR @ShadowDancer I guess we could send previewer a message with the cursor position. That way it could identify the active element and activate it in TabControl accordingly

ForNeVeR commented 4 years ago

@rstm-sf, isn't it something that you were preparing for the web previewer?

rstm-sf commented 4 years ago

As far as I understand, no. I was just doing mouse handling on preview. Here is a request for the editable element in xaml to be activated in preview

kekekeks commented 4 years ago

The web part has nothing to do with previewer<->editor communication, it's done via a separate tcp connection.

ForNeVeR commented 4 years ago

Why do you think that editor communication is important here? As I understand, this is about keeping control state between XAML updates in previewer. Though, if editor could help with this, them I'm all ears.

kekekeks commented 4 years ago

when editing the XAML contents of a <TabItem> the designer will switch to that tab

ForNeVeR commented 4 years ago

Ah, okay, you're right. Yes, it would be very easy to send current caret position to the previewer. Please consider that all the Avalonia-compatible editors (including VS, VSCode, Rider) have some sort of multi-caret, so it would be cool to be able to highlight multiple carets in future (though this is not that important).

ShadowDancer commented 4 years ago

I think this is a bit of over-engineering, because - as I understand it - there would be special concept for tab control, to change tabs based on what it sees in designer. However I think this is not really robust, because next things will soon follow, like scroll scrollviewer to edited item etc.

I think what we really need here is Xaml hot-reload, so user may choose tabitem he wishes, and then find the subtree which needs to be modified and only that subtree is reloaded in previewer. Do we have plans to support it?

kekekeks commented 4 years ago

there would be special concept for tab control, to change tabs based on what it sees in designer like scroll scrollviewer to edited item etc.

BringIntoView