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
Post a Comment