WPF CustomControl can't inherit from TextBlock control -


i'm making wpf customcontrollibrary customcontrols inherit standard controls label, textbox etc. when try make customcontrol inherit textblock, strange errors. seems customcontrol can't inherit textblock.

but why?

thanks in advance!

i have created custom control inherited textblock:

using system.windows.controls; namespace wpfapplication1 {     public class customtextblock : textblock     {     } } 

and used within same project:

<window x:class="wpfapplication1.mainwindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:local="clr-namespace:wpfapplication1">     <grid>         <local:customtextblock text="hello" />     </grid>         </window> 

so anser is:

you can inherit textblock

however, in order t use in xaml, have compile project first. there may other errors in code prevents project compile , therefore may getting errors

the type 'local:customtextblock' not found. verify not missing assembly reference , referenced assemblies have been built

or simmilar error:

the name "customtextblock" not exist in namespace "clr-namespace:wpfapplication1".

once fix other errors, these disappear well.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -