radRating with Lightswitch

2 posts, 0 answers
  1. Supreet
    Supreet avatar
    19 posts
    Member since:
    Mar 2011

    Posted 07 Jan 2012 Link to this post

    Hello,
       I am trying to use radRating control with a Lightswitch application.
    I am using it within a DataGrid for which the columns are generated on the fly.

    One of these columns has to be a Rating Control column.

    To achieve this I've done a simple POC 
    Here is what I've tried.

    XAML on my User Control
    <UserControl> 
    <UserControl.Resources>
            <!--<local:DateTimeConverter x:Key="DateConverter" />-->
            <DataTemplate x:Key="myCellTemplate">
                <rate:RadRating x:Name="myRatingControl"/>
            </DataTemplate>
        </UserControl.Resources>

        <Grid x:Name="LayoutRoot" Background="White">
            <telerik:RadGridView Name="radGridView1" AutoGenerateColumns="False"></telerik:RadGridView>
        </Grid>
    </UserControl>

    C# code
    Binding bind = new Binding();
                            bind.Path = new System.Windows.PropertyPath("childClass");
                            bind.Converter = new FeedbackValueConverters();
                            bind.ConverterParameter = i;
                            bind.Mode = BindingMode.TwoWay;

                            dg.Columns.Add(new GridViewDataColumn
                            {
                                Header = header,
                                IsReadOnly = true,
                                CellTemplate= (DataTemplate)dgAttendance.Resources["myCellTemplate"],
                                CellEditTemplate = (DataTemplate)dgAttendance.Resources["myTextBoxCellTemplate"],
                                DataMemberBinding = bind
                            });

    With this I do see the columns generated with rating control but When I make changes to the value of any of these rating controls, Convert Back () method of value converter is not being called??

    Is there something that is missing because of which the UI is not firing the event where the change has to be captured back in code?

    Any help is appreciated.

    Thanks & Reagrds
    Supreet
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 11 Jan 2012 Link to this post

    Hi Supreet ,

    Could you please check out this article and let us know if it helped you? Please notice that the control in the CellTemplate needs to have its Binding defined too:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Salary}">
     <telerik:GridViewDataColumn.CellTemplate>
      <DataTemplate>
       <telerik:RadNumericUpDown Value="{Binding Salary}" />
      </DataTemplate>
     </telerik:GridViewDataColumn.CellTemplate>
    </telerik:GridViewDataColumn>
    Actually you are specifying once the DataContext for the cell with the DataMemberBinding and then you are specifying the property to bind to.
    Having this in mind, please try to re-factor your code to set the binding and converter in your XAML. You can also check out the attached project. Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top