Binding RadComboBox Width

5 posts, 0 answers
  1. Pranama Moorthy
    Pranama Moorthy avatar
    26 posts
    Member since:
    Jun 2010

    Posted 17 Sep 2010 Link to this post

    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.




  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 17 Sep 2010 Link to this post

    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
  3. DevCraft banner
  4. Pranama Moorthy
    Pranama Moorthy avatar
    26 posts
    Member since:
    Jun 2010

    Posted 17 Sep 2010 Link to this post

    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.

     

  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 17 Sep 2010 Link to this post

    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
  6. Pranama Moorthy
    Pranama Moorthy avatar
    26 posts
    Member since:
    Jun 2010

    Posted 19 Sep 2010 Link to this post

    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
Back to Top
DevCraft banner