Gu.Wpf.NumericInput icon indicating copy to clipboard operation
Gu.Wpf.NumericInput copied to clipboard

Select namespace is not recognized

Open valimaties opened this issue 5 years ago • 5 comments

Hi. I'm a newbie in WPF. Can you tell me why VS it tells me that SelectAllOnGotKeyboardFocus is not recognized?

<UserControl x:Class"..."
             xmlns:ni="http://gu.se/NumericInput"
             xmlns:sel="http://gu.se/Select"
             > 
    ...
    ...
                              <!-- Here it tells me that Attachable property was not found in type TextBox -->
    <StackPanel x:Name="MySP" sel:TextBox.SelectAllOnGotKeyboardFocus="True"> 
        <ni:IntBox ........ />
    </StackPanel>
    ...
</UserControl>

My project is built as .Net 5 project. Does it matter? It does not tells me that is incompatible!

Thanks!

valimaties avatar Nov 26 '20 08:11 valimaties

I think this may be a bug in the WPF designer, does it work when you run the application? If you are new to WPF sadly one thing to learn is that the designer is full of false warnings. Many developers disable it altogether and write xaml using text editor only.

Please report back if it works as intended when you run the app, if so I don't think there is much we can do about it.

JohanLarsson avatar Nov 26 '20 09:11 JohanLarsson

Hi Johan. It's not a warning, it's an error. I cannot compile. I use the latest VS preview version, if matters 🙁 I found a workaround, by using GotFocus event, till I figure out what's going on.

PS: also, the designer crushes a lot... I will temporary delete this library to see if it is something wit it or it's from VS 🙁 very annoying

valimaties avatar Nov 26 '20 15:11 valimaties

Try clone and build this: https://github.com/JohanLarsson/SelectOnFocusRepro I get some false errors but it builds and runs fine.

About how we can fix this it may be tricky if it is a bug in the designer.

I tried explicit fully qualified but still getting the error. xmlns:select="clr-namespace:Gu.Wpf.NumericInput.Select;assembly=Gu.Wpf.NumericInput"

One thing we could try is deprecate this API and add a new class

public static class Select
{
    attached property AllOnKeyboardFocus
}

Changing class name could potentially make the designer less confused.

JohanLarsson avatar Nov 26 '20 17:11 JohanLarsson

I tried your solution. Indeed, it work, as it compile and run app, but still get that strange error. Did you opened a ticked on Microsoft's developers community?

Thanks!

valimaties avatar Nov 26 '20 17:11 valimaties

I did not open a ticket, if you feel like doing it feel free to use the repro linked above,

JohanLarsson avatar Nov 26 '20 17:11 JohanLarsson