Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select namespace is not recognized #45

Open
valimaties opened this issue Nov 26, 2020 · 5 comments
Open

Select namespace is not recognized #45

valimaties opened this issue Nov 26, 2020 · 5 comments

Comments

@valimaties
Copy link

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!

@JohanLarsson
Copy link
Member

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.

@valimaties
Copy link
Author

valimaties commented Nov 26, 2020

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

@JohanLarsson
Copy link
Member

JohanLarsson commented Nov 26, 2020

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.

@valimaties
Copy link
Author

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!

@JohanLarsson
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants