Read C# Textblock Text Property filled using Inlines

后端 未结 1 1343
遇见更好的自我
遇见更好的自我 2021-01-23 06:32

Let us say that I have an empty Textblock :

textblock1.Text = \"\";

Then I only put Inlines content in it with these two statements:



        
相关标签:
1条回答
  • 2021-01-23 07:02

    Just to elaborate on my comment to give some meaning,

    From MSDN Docs

    Loaded entails that the logical tree that an element is contained within is complete

    which helps us since the binding here has a reference to the other TextBlock element. Bindings also depend on DataContext and few other factors relative to the specific Binding but in general they get evaluated after the UI Loads for good reason.

    Hence setting the Text of the source TextBlock once the UI loads results in everything working fine since Binding's are active at that point.

    0 讨论(0)
提交回复
热议问题