Click here to Skip to main content
15,886,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to Bind the TextBlock inside ComboBox through Code. I am able to bind the textblock sucessfully but For some reasons TextBlock doesnt display Text Values.

I have mechanism which checks for the selected values and there I am getting the selected values without any problem.

So to conclude, My binding is working fine but I am missing out something hence textblock is not displaying text that is bound with it.

This is the code I am using for Binding:
where "lObjTextBlock" is TextBlock inside of ComboBox.
C#
Binding lObjBinding = new Binding();

lObjBinding.Path = new PropertyPath("[" + lObjMap.PropertyName + "]");
                                  
lObjTextBlock.SetBinding(TextBlock.TextProperty, lObjBinding);


This is the XAML for the TextBlock:
<my:HComboBox Name="cmbRefDoctor">
	<my:HComboBox.ItemTemplate>
		<DataTemplate>
                    <TextBlock x:Name="txtRefDoctorName" />
		</DataTemplate>
	</my:HComboBox.ItemTemplate>
</my:HComboBox>



Once again : My problem is that TextBlock is not displaying any Text althought values are being set.

Would love to get all possible suggestions. Thanks in advance.
Posted
Updated 3-Oct-12 19:28pm
v4
Comments
sant.rajas 4-Oct-12 9:50am    
Later on I realized that Using LoadContent gives the another instance of TextBlock so its of no use to me.

Now I am trying to find the other way to do same thing.

To Find the TextBlock control and then bind it in code behind.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900