We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Accessing Control Inside ContentTemplate

Hi,

I am currently using Syncfusion version 11.1.0.21, and am trying to access control inside SfAccordion.ContentTemplate. My code looks like this:

<syncfusion:SfAccordion ItemsSource="{Binding Items}" DisplayMemberPath="Name" SelectionMode="ZeroOrOne">
                <syncfusion:SfAccordion.ContentTemplate>
                    <DataTemplate>
                        <Border>
                            <Grid>
                                <playerframework:MediaPlayer x:Name="targetPlayer" Source="{Binding SomeUrl}" />
                                <Border>
                                    <Button x:Name="targetButton"/>
                                </Border>
                            </Grid>
                        </Border>
                    </DataTemplate>
            </syncfusion:SfAccordion.ContentTemplate>
</syncfusion:SfAccordion>

Please provide solution on how to:
  1. get "targetPlayer" and "targetButton" in my code behind? (I want to play the video programmatically, for example)
  2. make the entire controls in SfAccordion.SelectedItem disabled and enabled when its "targetButton" is clicked (the button itself is not affected, of course)
  3. Stop the player when SelectionChanged occured and on the previous SelectedItem, "targetPlayer" is playing a media.
Any simple C# and XAML codes or  samples are appreciated. 

Thanks in advance!

Regards,
Handre

6 Replies

SB Suresh B Syncfusion Team November 13, 2013 12:31 PM UTC

Hi Handre,

Thanks for using Syncfusion products.

We have created a simple sample to achieve your requirement and you can find the sample under the following location:

In the sample, we have created a accordion to in that ContentTemplate  we have  button and mediaplayer control . By default the player isenabled is false, when user click the button then player is enabled, Also in Selectionchanged event the previous player has been stopped.

Please let us know in case of any other queries,

Thanks and Regards,
Suresh B



SB Suresh B Syncfusion Team November 13, 2013 12:31 PM UTC

Hi Handre,

Thanks for using Syncfusion products.

We have created a simple sample to achieve your requirement and you can find the sample under the following location:

In the sample, we have created a accordion to in that ContentTemplate  we have  button and mediaplayer control . By default the player isenabled is false, when user click the button then player is enabled, Also in Selectionchanged event the previous player has been stopped.

Please let us know in case of any other queries,

Thanks and Regards,
Suresh B



HA handre November 18, 2013 04:21 AM UTC

Hi Suresh,

Thanks a lot for the sample. I actually have to rewrite the code in your samples into new sample project because the sample won't run. Well in the end, it runs beautifully and that's all that matters.

So basically, user select an accordion item then select a button, and the sample does this:
            Grid grid = GetParentItem(sender as DependencyObject) as Grid;
            IEnumerable<MediaPlayer> textBoxes = FindVisualChildren<MediaPlayer>(grid)
to get list of control (MediaPlayer). In my case, I want to do certain things (say, to enable a MediaPlayer or to change text of a TextBox) in a selected accordion item right when user selects an accordion item. In the accordion SelectionChanged event handler, I've tried few things and none have worked so far.
Could you do something about it?

Oh, we're of interested in accordion and basic charts lately. I wonder if you could provide one sample of simple basic line chart hosted inside accordion item (like, we have 3 or 4 accordion item where on each item we put a basic line chart with 1 or 2 series of data). That would be awesome.

Thank you,
Handre


VV Vignesh V Syncfusion Team November 21, 2013 02:23 AM UTC

Hi Hadre,

Query1: Enabling media player when user selects an SfAccordionItem

We have attached a sample in which we have taken the media player and enabled it during selectionchanged.

Sample Link: AccordianSample1.zip


Query2: Basic charts in AccordionItem

Please find the sample for adding chart in SfAccordionItem.



Please let us know if you need further assistance.

Regards,
Vignesh V


HS hassan salman March 1, 2018 03:44 PM UTC

hi, the download link for the examples does not work.


DR Durga Rajan Syncfusion Team March 6, 2018 06:44 PM UTC

Hi Handre, 

We regret to inform that the provided sample links are broken. Now, we have created new samples in UWP based on your requirement. Since Syncfusion no longer working further improvements for WinRT products, we suggest you to use UWP. UWP is a part of Windows 10 and Windows 10 Mobile. We have all the controls in UWP that are available in WinRT.  Please refer to the below link for more information on this, 
  


In this sample we have play the Video when the “Play” button is clicked and stopped the playing video which is in last selected item. Please download the sample for the same from below location, 
  

 Also we have prepared sample on hosting Chart control inside the Accordion Item. Please download the sample for the sample, 


Please get back to us with more details if the above sample doesn’t meet your requirement.  

Regards, 
Durga S. 


Loader.
Live Chat Icon For mobile
Up arrow icon