Skip to main content

Microsoft Silverlight

Answered Question Customizing ComboBox Control with BlendRSS Feed

(0)

Aravindakumar.V
Aravinda...

Member

Member

157 points

39 Posts

Customizing ComboBox Control with Blend

I am trying to  customize a combobox control to look like split button control (http://blogs.msdn.com/jfoscoding/archive/2005/11/10/491535.aspx) in Blend by Editing the template of ComboBox where in I have placed a button control in the place of the textblock control to give that apperance . Now I have to bind the control of Button Click event to ComboBox Click event. Can anybody help how can I do that?

Raju Hosamani
Raju Hos...

Member

Member

300 points

54 Posts

Answered Question

Re: Customizing ComboBox Control with Blend

Hi Aravindakumar,

we can bind any control event to any other control event.

There is no click event for combobox, so we can call SelectionChanged event of combobox in button's click event, as shown below code

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e){

}

private void Button_Click(object sender, RoutedEventArgs e){ComboBox_SelectionChanged(null, null);

}

If both Child (button ) and parent (combobox) events eventArgs are same, then we can map  child control event to parent control in .XAML, as shown below

<ComboBox MouseLeftButtonDown="ComboBox_MouseLeftButtonDown">

<ComboBox.Items>

<Button Content="Click" Width="70" Height="25" MouseLeftButtonDown="ComboBox_MouseLeftButtonDown"/>

</ComboBox.Items>

</ComboBox>

Please mark it as answered, if this meets your requirement
Thanks,
Raju

Aravindakumar.V
Aravinda...

Member

Member

157 points

39 Posts

Re: Customizing ComboBox Control with Blend

Hi, You idea holds good for external controls but the thing is I am customizing the template of the ComboBox to place a button and group the controls to form ComboBox again, in that case whether the internal controls are exposed outside for event subscription like you have specified?

Raju Hosamani
Raju Hos...

Member

Member

300 points

54 Posts

Re: Customizing ComboBox Control with Blend

Aravindakumar.V:
whether the internal controls are exposed outside for event subscription like you have specified?

 

YES internal controls are ALSO exposed outside for event subscription like I shown in above example

Please mark it as answered, if this meets your requirement
Thanks,
Raju

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities