Accessing a DevExpress TableView within a DevExpress TreeListView Column - tableview

I have dxg:TableView which sits inside the column of a dxg:TreeListView. This all works fine, however when I attempt to access the dxg:TableView in the code behind, it is invisible to the interpreter. I can access the TreeListView without issue using...
// Works as Expected.
var focusedState = (StateType)StatesView.FocusedNode.Content;
// LocationView is Not visible to debugger or interpreter.
var focusedLocationInStateRow = (LocationType)LocationView.FocusedNode.Content;
My goal is to get the Location row (can be 1 of many) selected within the State row. Locations are a collection within the State data model. Records are to be removed via the DeleteLocationRow Button method.
private void DeleteLocationRow(object sender, RoutedEventArgs e)
How does one access a TableView/GridView object within a TreeListView Column?
WPF Markup:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<dxg:TreeListControl x:Name="StateGrid"
AllowLiveDataShaping="True"
SelectionMode="Cell"
Margin="16.5,0,0,0"
SelectedItem="{Binding SelectedState}"
ItemsSource="{Binding MyStates}">
<dxg:TreeListControl.Resources>
<Style x:Key="SummaryStyle" TargetType="Run">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="dxp:TextExportSettings.FontFamily" Value="Arial Narrow"/>
</Style>
</dxg:TreeListControl.Resources>
<dxg:TreeListControl.Columns>
<dxg:TreeListColumn Header="Name" Width="190" FieldName="Name" />
<dxg:TreeListColumn Header="State Id" Width="80" FieldName="StateId" />
</dxg:TreeListColumn>
<dxg:TreeListColumn
AllowEditing="true"
Header="Locations"
Width="Auto">
<dxg:TreeListColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding RowData.Row.Locations, Converter={valueConverters:LocaleIdsTextValueConverter}}"/>
</DataTemplate>
</dxg:TreeListColumn.CellTemplate>
<dxg:TreeListColumn.CellEditTemplate>
<DataTemplate>
<dxg:GridControl
x:Name="LocationGrid"
ItemsSource="{Binding RowData.Row.Locations}"
HorizontalAlignment="Stretch"
Height="100"
Width="525"
AutoGenerateColumns="AddNew"
EnableSmartColumnsGeneration="True"
SelectionMode="Cell">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="LocationId" FieldName="LocationId" SortIndex="0" Width="100" AllowEditing="true">
<dxg:GridColumn.EditSettings>
<dxe:SpinEditSettings MaskType="Numeric" Mask="d" MinValue="1" MaxValue="100"
ShowText="{Binding Path=RowData.Row.IsNode}"
IsTextEditable="{Binding Path=RowData.Row.IsNode}"
IsEnabled="{Binding Path=RowData.Row.IsNode}" />
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="Incorporated Date" SortIndex="1" SortOrder="Ascending" Width="110" FieldName="IncorporatedDate" AllowEditing="true">
<dxg:GridColumn.EditSettings>
<dxe:DateEditSettings MaskType="DateTime"
Mask="MM/dd/yyyy HH:mm"
MaskUseAsDisplayFormat="True"
dxe:DateTimeMaskOptions.DateTimeKind="Local"
NullText=""
AllowNullInput="True"
ValidateOnEnterKeyPressed="True"
ValidateOnTextInput="True">
<dxe:DateEditSettings.StyleSettings>
<dxe:DateEditNavigatorWithTimePickerStyleSettings/>
</dxe:DateEditSettings.StyleSettings>
</dxe:DateEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="Delete Rows" Width="100">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<Button Click="DeleteLocationRow">
Delete Row
</Button>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView
Name="LocationView"
NavigationStyle="Cell"
AutoScrollOnSorting="False"
NewItemRowPosition="Bottom"
HorizontalScrollbarVisibility="Hidden"
ShowColumnHeaders="True"
ImmediateUpdateRowPosition="False"
AllowSorting="True"
AllowEditing="True"
ShowIndicator="True"
ShowGroupPanel="False"
ShowTotalSummary="False"
ShowFilterPanelMode="Never"
CellStyle="{StaticResource CustomLocaleCellStyle}"
ShowAutoFilterRow="False">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</DataTemplate>
</dxg:TreeListColumn.CellEditTemplate>
</dxg:TreeListColumn>
<dxg:TreeListColumn Header="City" Width="60" FieldName="City" />
</dxg:TreeListControl.Columns>
<dxg:TreeListControl.View>
<dxg:TreeListView Name="StatesView"
TreeDerivationMode="HierarchicalDataTemplate"
AutoExpandAllNodes="True"
AllowConditionalFormattingMenu="True"
AutoScrollOnSorting="False"
ShowEmptyText ="False"
AutoWidth="False"
ShowExpandButtons="True"
ShowRootIndent="True"
ShowAutoFilterRow="True"
NavigationStyle="Cell"
ImmediateUpdateRowPosition="False"
EnableImmediatePosting ="True"
AllowSorting="False"
AllowEditing="True"
ShowIndicator="False"
ClipboardCopyOptions="All"
ClipboardMode="Formatted"
ShowTotalSummary="True"
ShowFilterPanelMode="Never"
EditorShowMode="MouseDown"
RowStyle="{StaticResource FocusedRowStyle}"
CellStyle="{StaticResource CustomCellStyle}"
AllowDataUpdateFormatConditionMenu="True">
<dxg:TreeListView.ColumnHeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" TextWrapping="Wrap"/>
</DataTemplate>
</dxg:TreeListView.ColumnHeaderTemplate>
</dxg:TreeListView>
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>

I was able to access the row information using the DataContext derived from the Button event.
private void DeleteLocationRow(object sender, System.EventArgs e)
{
_isUpdating = true;
// Remove Row from Data set
var m = MessageBox.Show("Do you really want to delete this row?", "Delete Row", MessageBoxButton.YesNo);
if (m == MessageBoxResult.Yes)
{
//Get the button that raised the event
var btn = (Button)sender;
//Get the row that contains this button
var dRow = ((GridCellData)btn.DataContext).Row;
var localIdRow = (LocationInfo)dRow; // Convert to My Type in Column Row
// Delete Record from OPR and LPC
LocaleIdManager.DeleteLocationId(SelectedDatabases, localIdRow);
}

Related

How to hide a Grid row and ListView column so that no empty space is visible?

I have two issues with Xamarin Grid and ListView.
(1) In ListView, I have seven columns. Based on a condition, the fifth and sixth columns need to be hidden in such a way that there is no blank space visible after forth column. I tried to set IsVisble=false but it shows blank space in between.
(2) Similar issue is with Grid. Inside a ContentView, I have Grid with ten rows. Based on certain condition, I want to hide rows seven and eight in such a way that the empty portion should get collapsed. User should not be able to view the empty row.
If from code-behind I try removing rows using the below code, I suspect the .XAML may crash as row numbers need to be reordered.
GridView gv = listview.View as GridView;
GridViewColumn cd = gv.Columns[0];
gv.Columns.Remove(cd);
gv.Columns.Add(cd);
For the grid problem, just be sure to use Binding to set the RowHeight dynamically.
So as soon as you want to hide those rows, you set the height to 0.
Code would look like this:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Test"
x:Class="Test.MainPage">
<StackLayout Margin="0,20,0,0">
<Grid RowSpacing="0" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="{Binding RowHeight}" />
<RowDefinition Height="{Binding RowHeight}" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Label Text="Row 1" Grid.Row="0" HorizontalTextAlignment="Center" />
<Label Text="Row 2" Grid.Row="1" HorizontalTextAlignment="Center" />
<Label Text="Row 3" Grid.Row="2" HorizontalTextAlignment="Center" />
<Label Text="Row 4" Grid.Row="3" HorizontalTextAlignment="Center" />
<Label Text="Row 5" Grid.Row="4" HorizontalTextAlignment="Center" />
</Grid>
<Button Text="Hide rows" Clicked="OnClicked" />
</StackLayout>
</ContentPage>
public partial class MainPage : ContentPage, INotifyPropertyChanged
{
private int _rowHeight = 50;
public int RowHeight
{
get => _rowHeight;
set
{
_rowHeight = value;
OnPropertyChanged();
}
}
public MainPage()
{
InitializeComponent();
BindingContext = this;
}
private void OnClicked(object sender, System.EventArgs e)
{
RowHeight = 0;
}
}
You can set the row Height to Auto and then bind the IsVisible property of the content you want to hide.

Collapse or make visible a custom tool - bindable application bar

I'm currently making a WP7 application with a pivot control. I am making use of a bindable application bar (not the default application bar) because I'm using MVVM in my application. I want to change the application bar displayed, depending on the pivot item I am currently on.
Because I'm using a custom application bar tool, I figured that I could collapse or make visible each application bar depending on which pivot item I'm on, however the application bar will not collapse and only the workout application bar shows in my application (also, is this because I define the workout bar last in my XAML?).
Will this type of tool not collapse?
XAML:
<Grid x:Name="LayoutRoot"
Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<controls:Pivot Title="{Binding Name}" LoadingPivotItem="pivotMain_LoadingPivotItem">
<controls:PivotItem Header="Details" Name="detailsItem">
<view:EditClientDetails/>
</controls:PivotItem>
<controls:PivotItem Header="Workouts" Name="workoutItem">
<ListBox>
<ListBoxItem>
<view:AddLunch/>
</ListBoxItem>
</ListBox>
</controls:PivotItem>
<controls:PivotItem Header="Diets" Name="dietItem">
<ListBox>
<ListBoxItem>
<view:AddDinner />
</ListBoxItem>
</ListBox>
</controls:PivotItem>
</controls:Pivot>
<!--
<Button FontSize="30" FontFamily="Segoe WP" Content="Add Workout" Height="80" HorizontalAlignment="Left" Margin="25,500,0,0" Name="addWorkout" VerticalAlignment="Top" Width="400" Click="addWorkout_Click" />
<Button FontSize="30" FontFamily="Segoe WP" Content="Add Diet" Height="80" HorizontalAlignment="Left" Margin="25,414,0,0" Name="addDiet" VerticalAlignment="Top" Width="400" Click="addDiet_Click" />
<Button FontSize="30" FontFamily="Segoe WP" Content="Edit Details" Height="80" HorizontalAlignment="Left" Margin="25,328,0,0" Name="editDetails" VerticalAlignment="Top" Width="400" />
-->
<Preview:BindableApplicationBar x:Name="AppBarEdit">
<Preview:BindableApplicationBarIconButton
Command="{Binding AddClientCommand}"
IconUri="/Images/appbar.add.rest.png"
Text="Edit" />
<Preview:BindableApplicationBarIconButton
Command="{Binding SaveClientCommand}"
IconUri="/Images/appbar.check.rest.png"
Text="Save Client" />
</Preview:BindableApplicationBar>
<Preview:BindableApplicationBar x:Name="AppBarDiet">
<Preview:BindableApplicationBarIconButton
Command="{Binding GenerateDietCommand}"
IconUri="/Images/appbar.add.rest.png"
Text="Generate" />
<Preview:BindableApplicationBarIconButton
Command="{Binding SaveDietCommand}"
IconUri="/Images/appbar.check.rest.png"
Text="Save Diet" />
</Preview:BindableApplicationBar>
<Preview:BindableApplicationBar x:Name="AppBarWorkout" Margin="-157,-70,157,70">
<Preview:BindableApplicationBarIconButton
Command="{Binding GenerateWorkoutCommand}"
IconUri="/Images/appbar.add.rest.png"
Text="Generate" />
<Preview:BindableApplicationBarIconButton
Command="{Binding SaveWorkoutCommand}"
IconUri="/Images/appbar.check.rest.png"
Text="Save Workout" />
</Preview:BindableApplicationBar>
</Grid>
Code (just in code behind at the moment for testing purposes):
private void pivotMain_LoadingPivotItem(object sender, PivotItemEventArgs e)
{
if (e.Item == workoutItem)
{
AppBarEdit.Visibility = System.Windows.Visibility.Collapsed;
AppBarWorkout.Visibility = System.Windows.Visibility.Visible;
AppBarDiet.Visibility = System.Windows.Visibility.Collapsed;
}
else if (e.Item == dietItem)
{
AppBarEdit.Visibility = System.Windows.Visibility.Collapsed;
AppBarWorkout.Visibility = System.Windows.Visibility.Collapsed;
AppBarDiet.Visibility = System.Windows.Visibility.Visible;
}
else if (e.Item == detailsItem)
{
AppBarEdit.Visibility = System.Windows.Visibility.Visible;
AppBarWorkout.Visibility = System.Windows.Visibility.Collapsed;
AppBarDiet.Visibility = System.Windows.Visibility.Collapsed;
}
The WP7 UI supports a single ApplicationBar, which is set via the PhoneApplicationPage.ApplicationBar property, the bindable app-bar is a wrapper over the framework class, so it still has this same constraint.
For what you are trying to do, I would just write a bit of code-behind. This does not 'break' the MVVM pattern.
Try setting the IsVisible property of the BindableAppBar. You can have multiple BindableAppBar . However Only one will be displayed at a time. So if you have set IsVisible of two AppBars to false, then the third will be displayed if it is set to True.
<bindableAppBar:BindableAppBar IsVisible="{Binding IsVisible1}">
<bindableAppBar:BindableAppBarButton IconUri="/Assets/AppBar/AppIcon1.png" Text="Text1"/>
</bindableAppBar:BindableAppBar>
<bindableAppBar:BindableAppBar IsVisible="{Binding IsVisible2}">
<bindableAppBar:BindableAppBarButton IconUri="/Assets/AppBar/AppIcon2.png" Text="Test2"/>
</bindableAppBar:BindableAppBar>

Collection Bind to expanded View won't update when new Items are added

I am using a Expander View in my MainPage that is Bind to a collection of "Account Categories" (each item in this collection has further a collection of Accounts)
The Bindings are all working fine, with a small glitch though. There is another page Where a user can Add new Accounts (Thus changing Accounts & Account Categories) now when I navigate back to the Main Page the Expander Control does not show updated values?
The binding is done on OnNavigatedTo event of the Main Page
The DataBase context file is generated by Sql Metal tool
(More on this here Using SQl Metal to generate DB files for wp7)
That means all my classes implement INotifyChanging & INotifyChangedEvents
Here is the XAML & C# code
private WalletDataContext context;
private ObservableCollection<AccountCategory> _accountCategories;
public ObservableCollection<AccountCategory> AccountCategories
{
get { return _accountCategories; }
set
{
if (_accountCategories != value)
{
_accountCategories = value;
NotifyPropertyChanged("AccountCategories");
}
}
}
public MainPage()
{
InitializeComponent();
//Initialize Data context
context = new WalletDataContext(WalletDataContext.DBConnectionString);
//Set page data context
this.DataContext = this;
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
//fetch all existing Account Categories
var accountCategoriesInDB = (from AccountCategory acctCat in context.AccountCategory
select acctCat);
//Update Page Collection
AccountCategories = new ObservableCollection<AccountCategory>(accountCategoriesInDB);
this.listBox.ItemsSource = AccountCategories;
base.OnNavigatedTo(e);
}
Here are the XAML bindings
<ListBox Grid.Row="0" x:Name="listBox">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<toolkit:ExpanderView Header="{Binding}" Expander="{Binding}"
ItemsSource="{Binding Accounts}"
HeaderTemplate="{StaticResource CustomHeaderTemplate}" ExpanderTemplate="{StaticResource CustomExpanderTemplate}">
<toolkit:ExpanderView.ItemTemplate>
<DataTemplate>
<Grid VerticalAlignment="Center" Height="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="0.105*"/>
<RowDefinition Height="0.105*"/>
<RowDefinition Height="0.789*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.366*"/>
<ColumnDefinition Width="0.634*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding AccountNumber}" Style="{StaticResource PhoneTextNormalStyle}" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Balance}" Style="{StaticResource PhoneTextSubtleStyle}" VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
</Grid>
</DataTemplate>
</toolkit:ExpanderView.ItemTemplate>
</toolkit:ExpanderView>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Any ideas on whats wrong?
Thanks for your help in advance..
The MainPage reloads the data from the context in the OnNavigatedTo method.
Make sure you save/mark the updated data to the context in the Add New Account page.

ProgressBar on Windows Phone 7 is not showing

I am trying to show a ProgressBar in my Windows Phone 7 app when the app is fetching data.
Here is my XAML:
<!--Panorama item one-->
<controls:PanoramaItem Header="headlines">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<Button Name="refresh" Margin="320,-630,0,0" Grid.ColumnSpan="2" Height="75" Width="75" BorderThickness="0" Click="refresh_Click">
<Button.Foreground>
<ImageBrush ImageSource="/DataCollector.Tone;component/Resources/refresh-pressed.png" />
</Button.Foreground>
<Button.Background>
<ImageBrush ImageSource="/DataCollector.Tone;component/Resources/refresh.png" />
</Button.Background>
</Button>
<TextBlock Text="from heraldsun" Margin="12,-30,0,0" Style="{StaticResource PhoneTextSubtleStyle}" Grid.ColumnSpan="2"></TextBlock>
<ProgressBar
Margin="0,-40,0,0"
x:Name="progressBar"
IsIndeterminate="true"
Visibility="Visible" Grid.ColumnSpan="2" />
<ListBox Name="headlines" Margin="0,10,-12,0" ItemsSource="{Binding Tones}" Visibility="Collapsed" Grid.ColumnSpan="2">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,17,0,17">
<!--Replace rectangle with image-->
<Image Source="{Binding ImageUrl}" Height="75" Width="100" Margin="12,10,9,0" VerticalAlignment="Top" />
<!--<Rectangle Height="100" Width="100" Fill="#FFE5001b" Margin="12,0,9,0"/>-->
<StackPanel Width="311">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--Double line list with image placeholder and text wrapping-->
</Grid>
</controls:PanoramaItem>
Here is the back end code:
// Load data for the ViewModel Items
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
if (!App.ViewModel.IsDataLoaded)
{
App.ViewModel.LoadData();
progressBar.Visibility = Visibility.Collapsed;
headlines.Visibility = Visibility.Visible;
}
}
I recommend using the PerformanceProgressBar from the toolkit.
It runs on the compositor thread, so it won't block with UI things.
In following code:
if (!App.ViewModel.IsDataLoaded)
{
App.ViewModel.LoadData();
progressBar.Visibility = Visibility.Collapsed;
headlines.Visibility = Visibility.Visible;
}
If App.ViewModel.LoadData() is a synchronous method, thant may be keeping your UI from updating.
Try putting entire MainPage_Loaded code into a seperate method and call it asynchronously.
If I'm reading your most recent comment correctly, the problem you have now is that the value of the visible is initialy true, because the data is loading, and then the binding never occurs again when the data is loaded. I would recommend hooking up to an event (and making it on the data model if need be)
App.ViewModel.OnDataLoaded += (s, e) => performanceProgressBar.Visibility = Visibility.Hidden

horizontal listbox that could be infinite circle scrolling

I would like to make a horizontal listbox that could be infinite scrolling (looping listbox/scrollviewer, or circular listbox/scrollviewer), means that when I scroll to its end, its would scroll over from beginning.
I have tried to make the listbox horizontal, but it wouldn't scroll so I put it inside a scrollviewer to have it scroll horizontally. However it's not the listbox that scroll and I need them somehow to scroll over from beginning.
This is what I have so far:
private void DoWebClient()
{
var webClient = new WebClient();
webClient.OpenReadAsync(new Uri("http://music.mobion.vn/api/v1/music/userstop?devid="));
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (var reader = new StreamReader(e.Result))
{
string s = reader.ReadToEnd();
Stream str = e.Result;
str.Position = 0;
XDocument xdoc = XDocument.Load(str);
var data = from query in xdoc.Descendants("user")
select new mobion
{
avlink = (string)query.Element("user_info").Element("avlink"),
nickname = (string)query.Element("user_info").Element("nickname"),
track = (string)query.Element("track"),
artist = (string)query.Element("artist"),
};
listBox.ItemsSource = data;
}
}
Mainpage.xaml
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="DataTemplate1">
<Grid/>
</DataTemplate>
<Storyboard x:Name="Storyboard1" RepeatBehavior="forever" Completed="Storyboard1_Completed">
<DoubleAnimation Duration="0:0:25" To="-2400" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="imagesScrollview" d:IsOptimized="True"/>
</Storyboard>
</phone:PhoneApplicationPage.Resources>
<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="8,563,-2400,2" Width="auto" x:Name="imagesScrollview" Opacity="1" Background="#FF3ED216" Grid.Row="1" RenderTransformOrigin="0.5,0.5">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<im:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ScrollViewer.RenderTransform>
<CompositeTransform/>
</ScrollViewer.RenderTransform>
<ListBox x:Name="listBox" Width="Auto" Height="Auto" Background="#FF3ED216" ManipulationCompleted="listBox_ManipulationCompleted">
<ListBox.RenderTransform>
<CompositeTransform/>
</ListBox.RenderTransform>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal">
<StackPanel.RenderTransform>
<TranslateTransform X="0" />
</StackPanel.RenderTransform>
</StackPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="15,0">
<Image Name="imageAV" Source="{Binding Path=avlink}" Height="80" Width="80" Stretch="UniformToFill" MouseLeftButtonUp="imageAV_MouseLeftButtonUp" ImageFailed="imageAV_ImageFailed" />
<StackPanel Orientation="Vertical" Margin="10,0,0,0" MouseLeftButtonUp="StackPanel_MouseLeftButtonUp">
<TextBlock Name="indexTextBlock" Text="{Binding num}" />
<TextBlock Text="{Binding nickname}"/>
<TextBlock Text="{Binding track}" FontWeight="Bold" />
<TextBlock Text="{Binding artist}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
To make a listbox scroll horizontally you need to set the ScrollBar Visibility properties of the internal ScrollViewer.
Like this:
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Disabled" >
The Toolkit includes a LoopingSelector class that you could based your own control implementation on. There's an example of creating such a control at http://babaandthepigman.wordpress.com/2010/09/22/wp7-looping-selector/ (although it is for a vertical list)
Not sure if that helps, but the standard approach to infinite scrolling is to put at least one screenful of duplicate items from the beginning of the list at the end, and upon reaching the end, transparently skip (1-step scroll) to the beginning or a fixed short offset from it (and vice versa) so that it looks the same but the user looks at the items from the beginning of the list, not their duplicates from the end.

Resources