I am using a HubSection as below:
<HubSection Header="Section1">
<DataTemplate>
<TextBox />
</DataTemplate>
</HubSection>
<HubSection Header="Section1">
<DataTemplate>
<TextBox />
</DataTemplate>
</HubSection>
<HubSection Header="Section1">
<DataTemplate>
<TextBox />
</DataTemplate>
</HubSection>
Now I am having a JSON from which I want to bind the textboxes inside all the HubSection
Below is the class for the JSON data:
class RootObject
{
public string Text1 { get; set; }
public string Text2 { get; set; }
public string Text3 { get; set; }
}
Now according to this question and this article, I can very well use the Loaded
event for the TextBox
as below and set the value.
<TextBox Loaded="TextBox_Loaded" />
private void TextBox_Loaded(object sender, RoutedEventArgs e)
{
var txtBox = (TextBox)sender;
txtBox.Text = "Some Text";
}
But the problem is that it will not be good to do so if I have few more controls to bind/access inside each of the HubSection
.
So can someone please tell me if there is another simple way to bind the controls.