Try creating a new method, for example InitUI, and move the initialization of the NewImage variable there
custom_ui := class:
NewTexture<protected> : texture = Widgets.Images.T_Robbery_MoneyBill_Bg
var MainCanvas<private>:canvas = canvas{}
InitUI():void=
var NewImage<private>:texture_block = texture_block {DefaultImage := NewTexture, DefaultDesiredSize := vector2{X:=300.0, Y:=170.0}}