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

How access controls in RowDetails?

4 Answers 76 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 02 Feb 2012, 11:50 PM
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

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Feb 2012, 07:36 AM
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 >>

0
Vlad
Telerik team
answered on 03 Feb 2012, 07:41 AM
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 >>

0
Rob Ainscough
Top achievements
Rank 1
answered on 06 Feb 2012, 10:04 PM
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
0
Maya
Telerik team
answered on 07 Feb 2012, 08:35 AM
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 >>
Tags
GridView
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Maya
Telerik team
Vlad
Telerik team
Rob Ainscough
Top achievements
Rank 1
Share this question
or