tags:

views:

169

answers:

2

Hi There,

i get an Exception during (UIElement)XamlReader.Load(...) which says

'Cannot create unknown type 'TextBox'.' Line number '1' and line position '2'.

on the following xaml:

<TextBox Name="inputMyFirstString" BorderThickness="0" HorizontalAlignment="Stretch" Text="test"></TextBox>

What did i wrong?

A: 

I think, this is due to missing namespace. Try

<TextBox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...
Anton Gogolev
This will work, but adding the namespace to every control in the XAML is not a good idea. Better to define it globally.
Winston Smith
That fixed it! Thanks!
elCapitano
@Winston Smith: i have defined the namespace in my control to which i add the textbox. Where else can i define the namespace globally?
elCapitano
A: 

Add the xmlns attribute to the Window element in your XAML:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" ...
Winston Smith
i did this, but this did not work
elCapitano