Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Add items to list data source after load
posted

I am using the datasource example from the sample viewer.  Here is what I would like to accomplish. 

I am using the carousel to list all of the file types in a specific directory.  My first attempt was to put a regular list box in the template

 

<DataTemplate x:Key="DocDataTemplate"> <Grid HorizontalAlignment="Center" Width="170" Height ="100">

 

 

<Grid.RowDefinitions>

 

 

 

 

 

<RowDefinition Height ="0.581*"/>

 

 

 <Image Stretch="Fill" Source="{Binding XPath=ImgPath, Mode=Default}"> </Image >

 

<ListBox Grid.Row="2" BorderBrush="Purple" BorderThickness="1" MouseDoubleClick
</Grid.RowDefinitions ><RowDefinition Height ="0.419*"/> 

="ListBox_MouseDoubleClick" >

 

<ListBoxItem>Test1</ListBoxItem>

 

<ListBoxItem>Test2</ListBoxItem>

 

<ListBoxItem>Test3</ListBoxItem>

 

</ListBox>

 

<!--<TextBlock

 

 

</Grid>

 

</DataTemplate>

 

Visually it looks great.  check out how I can select an item.  I have even hooked its double click event... but I have no way of getting to each list box to add the directory info for each file type.

 

I guess my ultimate question would be how is the best way to go about this.  can I get to the list box by way of the carousel item with regular C# code?  So far I only see the xml code not the listbox object instance.

Could I bind to a dataset and add items without using the list box... while retaining the double click event so that I can allow my users to indicate which item the would like?  thanks!

 

TextWrapping="Wrap"

Margin="0,0,0,0"

VerticalAlignment="Center"

Width="Auto"

Height="Auto"

Grid.Row="1"

Text="{Binding XPath=Summary, Mode=Default}"

FontSize="10"

HorizontalAlignment="Left"/>-->

  • 69686
    posted

    Hello,

    You should get the listbox instance as a Content of the CarouselListBoxItem. I have created simple example and the thing I think you are trying to achieve should look something like this :

               var a = xamCarouselListBox1.Items[0];
               ListBox listbox = (a as CarouselListBoxItem).Content as ListBox;
               listbox.Items.Add("test5");

    Let me know if that is helpful.

    Alex.