How to bind data to combobox inside datagrid using sliverlight

Posted by Kalyani under Silverlight on 2/25/2010 | Views : 30132 | Status : [Member] | Replies : 7
Hi Vuyiswamb ,
Hope ur doing good. load event and combbox is not visible in Datagrid..
Loaded="ddlSource_Loaded" event is not working .plz help me


xaml code
<data:DataGrid x:Name="travelReqGrid" AutoGenerateColumns="False" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch" BorderThickness="1"

CanUserResizeColumns="false" FontFamily="Verdana" FontSize="9" AreRowDetailsFrozen="False" RenderTransformOrigin="0.5,0.5" d:LayoutOverrides="VerticalAlignment, GridBox" Margin="-2,0,36,0" >

<data:DataGrid.Columns>
<data:DataGridTemplateColumn Header="Source" Width="158">

<data:DataGridTemplateColumn.CellEditingTemplate>

<DataTemplate >

<ComboBox DisplayMemberPath="value" HorizontalAlignment="Left" x:Name="ddlSource" ItemsSource="{Binding ddsour, Source={StaticResource Travels}}" SelectedItem="{Binding dissource, Mode=TwoWay}" Width="150" Height="23" KeyDown="ddlSource_KeyDown" Loaded="ddlSource_Loaded" >

</ComboBox>

</DataTemplate>

</data:DataGridTemplateColumn.CellEditingTemplate>

</data:DataGridTemplateColumn>
<data:DataGrid.Columns>





Responses

Posted by: Abhi2434 on: 2/25/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Hey nisithraj,

Did you read the question properly before you answer. Dont put a blank line just to increase your post count rather, if you have something to input, you should reply.

Well, regarding the issue, I think you should have to handle DataGrid event (probably SelectionChanged) and traverse the VisualTree to find your Combobox.

In fact, I never did used Datagrid, I rather always use ListBox and use DataTemplate to properly produce my UI.

public static childItem FindVisualChild<childItem>(DependencyObject obj) where childItem : DependencyObject

{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(obj, i);
if (child != null && child is childItem)
return (childItem)child;
else
{
childItem childOfChild = FindVisualChild<childItem>(child);
if (childOfChild != null)
return childOfChild;
}
}
return null;
}


This might come handy to your need.

Cheers.

www.abhisheksur.com

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/25/2010 [Member] Bronze

Up
0
Down
Hey... don't loose your temper unnecessarily.

Actually I mistakenly thought the question has raised in the asp.net section. And my intention is not to increase the post counts just like that(infact your count is more than me and I don't know how many valid answers you are provided). Mistakes are human nature and loosing temper for that is not at all good.


However, Kalyani. There is a good example provided in the following link(for the load event of a combo box in a grid). Kindly check it out...

http://forums.silverlight.net/forums/t/53435.aspx

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/25/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Nishithraj and Abhi2434

Remember we are Friends let us not fight amongst each other guys. Nishithraj Please make sure next time that you read the question clearly and i have noticed that some of your links are not fine, its like you have a link nested. just try to put each link under its on link tag. Abhi2434 and Nishithraj please promise me you will not fight again.

Thank you for being part of Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/25/2010 [Member] Bronze

Up
0
Down
Vuyiswamb ,

Okey, thanks for pointing out the mistakes. I'll take care while using the link tag.
According to me we should have only one intention through this site. i.e, helping others technically. I am ready to share the knowledge, whatever I know. I just justified myself here.

I don't have any more conflicts with abhi.... :)


Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/25/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Am now happy to hear that.

Thank you friend.

Thank you for posting at Dotnetfunda
[Administrator]

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi2434 on: 2/27/2010 [Member] [Microsoft_MVP] [MVP] Silver

Up
0
Down
Ha ha ...
I dont have any problems with Nisithraj. I just saw this today. ha ha .. .Really amazing reply he made.

Its our duty to keep the forum clean. Vuyiswamb, you are doing great in the forum.

:)

www.abhisheksur.com

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 3/1/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Abhi2434

Am glad you feel that way.

Thank you

Thank you for posting at Dotnetfunda
[Administrator]

Kalyani, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response