This is a migrated thread and some comments may be shown as answers.

Binding RadComboBox Width

4 Answers 81 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Pranama Moorthy
Top achievements
Rank 1
Pranama Moorthy asked on 17 Sep 2010, 10:56 AM
Hi telerik team,
                             I have created my own control, which uses a RadCombo Box control, but for my control I have a double property called ControlWidth (for which I am raising a property changed event). I use this property to set my RadCOmboBox's width. Now the problem is, the width I am specifying does not seem to work.. when I try to bind to it.., it does not pick up the value I pass to the usercontrol..

Below is what I am doing... in the usercontrol (My User control has the below radCombo box and Binding)

 

 

 

<telerikInput:RadComboBox x:Name="referenceDataComboBox" Grid.Column="0" Width="{Binding ControlWidth}"

 


Within the Code behind of UserControl have put in this property, so that I can set this property via my usercontrol

 

 

private string controlWidth = "0";

 

 

 

public string ControlWidth

 

{

 

 

get

 

{

 

 

return this.controlWidth;

 

}

 

 

set

 

{

 

 

this.controlWidth = value;

 

 

 

this.RaisePropertyChanged("Width");

 

}

}


Please advice what I am doing wrong here, that the binding is not being picked up.




4 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 17 Sep 2010, 11:19 AM
You need to modify the following code:

this.RaisePropertyChanged("Width");

to

this.RaisePropertyChanged("ControlWidth");

In other words, the PropertyChanged event should be raised with the name of the CLR property that was changed.

Please, let me know if I am missing something.

All the best,
Valeri Hristov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pranama Moorthy
Top achievements
Rank 1
answered on 17 Sep 2010, 11:27 AM
Hi Valeri,
                I tried it with said, but still I Couldnt get it to work. My Usercontrol Call is as below.

 

 

 

<referenceData:ReferenceDataComboBox Grid.Column="1" Grid.Row="0" Margin="0,10,10,2" x:Name="marketerNameRefData"

 

 

 

DisplayMemberPath="MarketerName" FilterStringMinLength="2" Height="24" ControlWidth="100"

 

 

 

FilterType="Name" ReferenceDataType="Marketer">

 

 

 

 

</referenceData:ReferenceDataComboBox>

 



As you can see above, I am using ControlWidth to set my Combo Box width, I ahve changed the raise property event changed also. Do you have any example? where in you have placed Radcombo in a usercontrol and when you set the userdefined property (like in this case ControlWidth), that you are able to set the width of the combo box, by using the below binding.

 

 

 

<telerikInput:RadComboBox x:Name="referenceDataComboBox" Grid.Column="0" Width="{Binding ControlWidth}"

 

 

 

KeyUp="referenceData_KeyUp" GotFocus="referenceData_GotFocus" SelectionChanged="referenceData_SelectionChanged"

 

 

 

IsEditable="{Binding Path=IsEditable}" DisplayMemberPath="{Binding Path=DisplayMemberPath}"

 

 

 

SelectAllTextEvent="None" IsTextSearchEnabled="True" IsFilteringEnabled="True" TextSearchMode="StartsWith"

 

 

 

CanKeyboardNavigationSelectItems="True" CanAutocompleteSelectItems="False"

 

 

 

IsReadOnly="False" ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="Clear Selection">

Please advice.

 

0
Valeri Hristov
Telerik team
answered on 17 Sep 2010, 12:30 PM
I see. The problem now is that the Binding has no source. I assumed that the DataContext of RadComboBox was set to a object that has the ControlWidth property. You could update the combobox binding to:
<telerikInput:RadComboBox Width="{Binding ControlWidth, ElementName=referenceDataControl}" ... />

where referenceDataControl is the name of the UserControl that contains the RadComboBox declaration (the one on the screenshot).

All the best,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Pranama Moorthy
Top achievements
Rank 1
answered on 19 Sep 2010, 06:43 AM
Hi Valreic,
                         I found out what the problem was, I had my  radcombobox within a stack panel,whoese orientation was set as horizontal, hence it took only the space that it needed. To fix this, I changed the stack panel to a grid, and then set the userocntrols width. Worked like a charm.!

THanks a lot for your time and help! much appreciated! :)

Regards,
Pranama
Tags
ComboBox
Asked by
Pranama Moorthy
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Pranama Moorthy
Top achievements
Rank 1
Share this question
or