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()
77
77
78
78
// Get value from view model.
79
79
var viewModelPropertyValue = viewModelProperty . GetValue ( ViewModel , null ) ;
80
- if ( viewModelPropertyValue = = null )
80
+ if ( viewModelPropertyValue ! = null )
81
81
{
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 ) ;
83
85
}
86
+ }
84
87
85
- InstantiateTemplate ( viewModelPropertyValue ) ;
88
+ protected override void OnTemplateDestroy ( Template template )
89
+ {
90
+ base . OnTemplateDestroy ( template ) ;
91
+ Destroy ( template . gameObject ) ;
86
92
}
87
93
}
88
94
}
You can’t perform that action at this time.
0 commit comments