How access controls in RowDetails?

5 posts, 0 answers
  1. Rob Ainscough
    Rob Ainscough avatar
    262 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2012 Link to this post

    How do I access via code behind (VB) the controls in a RowDetails DataTemplate?

    Example XAML:
    <DataTemplate x:Key="TransactionDetailDataTemplate">
        <Grid MinHeight="28" Style="{StaticResource RowDetailBackground}">
     
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="680"/>
                <ColumnDefinition Width="100"/>
            </Grid.ColumnDefinitions>
     
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
             
            <ListBox x:Name="TransactionDetailListBox" Margin="100,0,0,0" Background="{x:Null}" DataContext="{Binding Source={StaticResource TransactionDetailData}}" BorderBrush="{x:Null}" FontSize="10.667">
                <ListBoxItem Content="{Binding Collection[0].Description1}" />
            </ListBox>
             
            <Button x:Name="WaiveFeeButton" Content="Wavie Fee" Grid.Column="1" Style="{StaticResource AcceptButton}" Visibility="Collapsed" />
             
        </Grid>
    </DataTemplate>

    In my code behind I have:

    Private Sub TransactionGridView_RowDetailsVisibilityChanged(sender As Object, e As Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs) Handles TransactionGridView.RowDetailsVisibilityChanged
     
        ' DEMO - for demo only
        If Not TransactionGridView.CurrentItem Is Nothing Then
     
            Dim RowObject As Object = TransactionGridView.CurrentItem
            If RowObject.TxDescription = "Charge" Then
                ' Make the Waive Fee Button Visible
     
            End If
     
        End If
     
    End Sub

    Code behind will not recognize the WaiveFeeButton as being directly accessible.  How can I set the visibility of this button in code behind?

    Rob

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Feb 2012 Link to this post

    Hi Rob,

    I would recommend you to work with the arguments of the event instead. Please refer to our online documentation for a reference. 

    Greetings,
    Maya
    the Telerik team

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

  3. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 03 Feb 2012 Link to this post

    Hi,

     I strongly suggest you to use MVVM pattern to achieve your goal. In this case you should bind Visibility of the Button to desired property in your model using IValueConverter. 

    Regards,
    Vlad
    the Telerik team

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

  4. Rob Ainscough
    Rob Ainscough avatar
    262 posts
    Member since:
    Jan 2010

    Posted 06 Feb 2012 Link to this post

    Sorry, but I find MVVM way too verbose and worky and far to imposing (restrictive).  I'm not a fan of MVVM, it forces a human interaction that is not natural to anyone other than developers and/or folks that think in logical patterns ... my end users are rarely those types of people.  MVVM may make sense from a developers perspective, but I'm not coding applications for developers and my end user rarely think the same way a developer does, very rare!  I'm not suggesting right or wrong, just the reality of real world applications over a broad audience/user.

    Back to the sample code from your link ... if I understand correclty, I can use the LoadingRowDetails and assign it to an event handler ... that's all good.  But specific details about the row will be available thru e (GridViewRowDetailsEventArgs)?

    Thanks,
    Rob
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 07 Feb 2012 Link to this post

    Hi Rob,

    Indeed, you can work with the arguments of the event - you can get the element defined in RowDetailsTemplate, the corresponding row and the state of the row details - whether they are visible or collapsed. 

    Regards,
    Maya
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top