0

I created custom class ingeriting from TextBox and I use it in one of my window. Class is in root of project so it's namespace is: Firm

To use this class from root of project I added line into xaml:

<Window x:Class="Firm.Prijem.PaletaWindow"
        ...
        xmlns:mynms="clr-namespace:Firm"> <--- ADDED LINE

       <mynms:SelectAllTextBox Name="textBoxMnozstvi" />
</Window>

But now when I try to run my code. I got error, because "name 'textBoxMnozstvi' does not exist in current context" on line:

 String text = textBoxMnozstvi.Text;

Why is that? Is now the textBoxMnozstvi in another namespace?

Sk1X1
  • 1,305
  • 5
  • 22
  • 50
  • 5
    have you tried ?? – adminSoftDK Sep 19 '16 at 08:56
  • Okey, that was easy.. thanks for help, if you can post this as answer I will marked as accepted... Will be best if you you could post even some reason why I have to use `x` now.. Thanks again – Sk1X1 Sep 19 '16 at 10:22

1 Answers1

1

Try this instead

<mynms:SelectAllTextBox x:Name="textBoxMnozstvi" />

There are already some good explanations on Name vs x:Name here

Community
  • 1
  • 1
adminSoftDK
  • 2,012
  • 1
  • 21
  • 41