File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -77,12 +77,18 @@ private void InitializeTemplate()
7777
7878 // Get value from view model.
7979 var viewModelPropertyValue = viewModelProperty . GetValue ( ViewModel , null ) ;
80- if ( viewModelPropertyValue = = null )
80+ if ( viewModelPropertyValue ! = null )
8181 {
82- throw new PropertyNullException ( $ "TemplateBinding cannot bind to null property in view: { ViewModelPropertyName } .") ;
82+ //some times property for binding can be null ( for example we must destroy our template ) and this case not wrong
83+ //throw new PropertyNullException($"TemplateBinding cannot bind to null property in view: {ViewModelPropertyName}.");
84+ InstantiateTemplate ( viewModelPropertyValue ) ;
8385 }
86+ }
8487
85- InstantiateTemplate ( viewModelPropertyValue ) ;
88+ protected override void OnTemplateDestroy ( Template template )
89+ {
90+ base . OnTemplateDestroy ( template ) ;
91+ Destroy ( template . gameObject ) ;
8692 }
8793 }
8894}
You can’t perform that action at this time.
0 commit comments