RadMediaPlayer in a ListBox DataTemplate

3 posts, 1 answers
  1. John Mitchell
    John Mitchell avatar
    3 posts
    Member since:
    Oct 2009

    Posted 31 Aug 2010 Link to this post

    I am trying to create a small reader type component that will have videos and links in them.  I am trying to put a RadMediaPlayer into the DataTemplate of a listbox and it crashes at runtime with:

    A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in System.Windows.dll


    My template is somewhat complex, but I have tried to simplfy it as much as possible:

     

    <ListBox x:Name="listNews" Background="{x:Null}" BorderThickness="0">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Vertical">
                    <TextBlock Text="{Binding GroupName}" VerticalAlignment="Top" FontSize="12" FontWeight="Bold"/>
                    <ListBox x:Name="listNewsInner" Background="{x:Null}" BorderThickness="0" ItemsSource="{Binding NewsItems}" SelectionChanged="listNewsInner_SelectionChanged">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid x:Name="newsItemRoom" Margin="0,0,0,10">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="30"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="26"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="75"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="45"/>
                                    </Grid.ColumnDefinitions>
      
                                    <telerik:RadMediaPlayer VerticalContentAlignment="Top" HorizontalContentAlignment="Center" SelectedIndex="0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">
                                        <telerik:RadMediaItem Header="Big Buck Bunny" Source="http://localhost:1146/Video/duck.wmv"></telerik:RadMediaItem>
                                    </telerik:RadMediaPlayer>
      
                                    <TextBlock Text="{Binding Caption}" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Top" FontSize="12" FontWeight="Bold"/>
                                    <TextBlock Text="{Binding Description}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" VerticalAlignment="Top"/>
                                    <TextBlock Text="{Binding Created}" Grid.Row="2" Grid.Column="2"/>
                                    <HyperlinkButton Content="More..." CommandParameter="{Binding LinkURL}" Grid.Row="2" Grid.Column="3"/>
                                </Grid>
      
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

    I have attempted to move this into the parent ListBox and that did not work; I attempted to move it OUT of the listbox [into the main xaml] and it worked just fine.  It just seems that the media player cannot function while in a datatemplate.

    I am using version 2010.2.821.1040 of the MediaPlayer.dll.

    Any help would be appreciated!

  2. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 03 Sep 2010 Link to this post

    Hi John,

    We are not aware of such issue with RadMediaPlayer. Please find attached my test project. Have a look at it and let me know if I am missing something. I'd be glad to further assist you.

    Best wishes,
    Kiril Stanoev
    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. John Mitchell
    John Mitchell avatar
    3 posts
    Member since:
    Oct 2009

    Posted 03 Sep 2010 Link to this post

    You are absolutely correct.  The problem came down to actually just referencing the RadMediaPlayer.  I had two projects -- a "user control" project and a "application" project.  I included a ref to MediaPlayer.dll in the "user control" project but NOT in the "application" project [which actually creates the xap].  For some reason, the MediaPlayer.DLL was not included in the xap until I made a reference to it in the "application" project.

    The problem was it was not giving me a "Type not found" error, it was giving me some kind of other crazy error that made it sound like something was wrong with the xaml that was being made when the mediaplayer we put into the control.

    Thank you for looking into this for me.

    John.
Back to Top