Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm looking to create an app that features a photo gallery, one that is almost exactly the same as the built in photo gallery/photos hub.
I've looked at using a Grid, but I can't bind data to it. I also looked at using a DataGrid, but that is not included in the Windows Phone SDK. The grid I need will have a set number of columns but a variable number of rows (like I said, just like the current built in photo gallery)
Does anyone have any suggestions/solutions?
Photo gallery is simply a listbox where every row is an horizontal stackpanel with images, add a little binding and you are ok ;)
It will work with a listbox, but you have to edit its ItemsPanelTemplate and use something like the WrapPanel control (horizontal orientation) from the toolkit. Then, you can define the ItemTemplate as a square image. That way every new item will stack at the right from the other until there's no more room and it will continue on the next row. So for a set number of columns, you have to specify the width in the item template (173 in my example so in the portrait mode, i end with 2 columns).
Here's a example from one of my projects (you should adjust bindings and names to your scenario):
<ListBox x:Name="lbxCategorias" ItemsSource="{Binding ChannelButtons}"
SelectionChanged="lbxCategorias_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Image Source="{Binding BigButtonIconPath}" Width="173" Height="173" Margin="0 0 12 10" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The Windows Phone SDK contains a Panorama/Pivot Control that mimics the functionality you see in the people or photos hub.
Here's a link to a code sample using this control:
http://msdn.microsoft.com/en-us/library/ff431744(v=vs.92).aspx
Scroll down to the Controls section of the samples page and the first item there is the Panorama Sample.
I'd also recommend taking a look at the section titled Cameras and Photos.
You can build a exact photo viewer like in wp7 using the horizontal looping selector with some modifications. Try to add the images in the item i think it helps you
http://blog.supaywasi.com/2011/06/horizontal-looping-selector/
Related
I am doing one project where I want display the office floor with two thousnads seats which will be user interactive and will be inside the wpf Viewport2DVisual3D and all the seats(cells) will have stack panel with image which is bound with data base items from table) I will be using scroller and zoomer for moving in the screen.My question is whetehr I have to use Grid view or List view(with conrol templates) for this purpose considering the performance and maintenance or is there any other option to do this. I am new to WPF please help me ?
A Canvas control can be used to place items with arbitrary pixel coordinates, maybe that could be usefull?
<Canvas>
<Stackpanel Canvas.Left="10" Canvas.Right="10"></Stackpanel>
<Stackpanel Canvas.Left="20" Canvas.Right="20"></Stackpanel>
</Canvas>
on Windows 8.1 below code indicates the selected item of GridView. But on Windows Phone Xaml same code doesn't work like that. There isn't any visual indicator for selected item at all.(or i couldn't get it to work) How can i make it work like this on Windows Phone App too?
<GridView
x:Name="productColorChoices"
SelectionMode="Single"
ItemTemplate="{StaticResource productColorChoice_ItemTemplate}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid
Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
If you go look at the GridViewItem default style template you'll see towards the bottom you have these objects in there;
SelectedBorder
SelectedCheckMarkOuter
SelectedCheckMark
SelectedEarmark
Which is what makes up the visuals for that selected outline/checkmark thingy on the GridView items. They all get shown according to the VisualState for Selected
Now, if you go and look at the phone's default style template for the GridViewItem's (which I couldn't find the default one for with a quick google search and I don't have a phone project open to go dig through) then you can compare. If these types of elements don't exist in the phone templates then you can go add them the same way using pretty much the same objects and the same storyboards in the same VisualState.
Hope this helps, cheers.
When my app is snapped displaying a GridView isn't the best way to present the information. I want to present it in a ListView instead. I also want to change the item template as well.
I currently have a UserControl that accepts the DataContext as the item template so I can simply create a new view and use that instead and it should work. So I'm basically looking to swap local:NormalDetailView with local:SnappedDetailView
Originally I thought about having both the ListView and GridView in there at the same time and adjusting the visibility based on snapped mode. But I had doubts about the performance about this technique.
Lastly, this is a LayoutAwarePage so I do have all that XAML stuff at the bottom about VisualStateManager.VisualStateGroups etc.
<GridView x:Name="GalleryGridView"ItemsSource="{Binding ListOfItems}">
<GridView.ItemTemplate>
<DataTemplate>
<local:NormalDetailView VerticalAlignment="Center" Width="250" Height="250" DataContext="{Binding}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
The performance is just fine if you use both a gridview and a listview, and adjust visibility depending on view state. This is exactly what the "split-application" template in Visual Studio does.
Just generate an app based on this template and take a look at ItemsPage.xaml and ItemsPage.xaml.cs. The other templates may also do this, but I haven't used them so I don't know for sure.
I have created a small WP7 app which contains one page which is dynamically filled with content. But it goes out of viewable area. Emulator doesn't scroll the page when I click-hold-move on the screen. How do I make it scroll when needed?
One simple option is to drop the content you require inside a ScrollViewer, so for example adding a large TextBlock as so:
<ScrollViewer Name="scrollViewer" ScrollViewer.HorizontalScrollBarVisibility="Visible" >
<TextBlock Height="30" Name="textBlock" FontSize="24"
Text="This is a long block of text which wont fit in the available area" />
</ScrollViewer>
Obviously, in most cases you will want to drop a container control such as Grid or StackPanel into the ScrollViewer and place all your other controls in there.
That said, I'm wondering if you are actually looking for some of the standard WP7 Metro look and feel controls such as the Panorama and Pivot Controls which are available in the latest dev tools - follow that link for full details.
Hi all i need to design a control that has a thumbnail views of picture.it can take list of pictures.i need it in wpf.is there any pre existed library of control?
if no how can i design i have no idea
Thanks
was looking something like http://www.codeproject.com/KB/graphics/crystal_image_grid_viewer.aspx?msg=3290254
If you have a list of pictures you can place a panel (StackPanel, WrapPanel, etc., depends on the behaviour you want) inside a ListBox. Set the panel to be the items host, and set the list of pictures as the ItemsSource. Something like this:
<ListBox x:Name="_listBox" >
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" IsItemsHost="true" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
and then in the code behind set _listBox.ItemsSource to your list of pictures.
(or you can have your list of pictures in an ObservableCollection and bind the ListBox to it)
EDIT: as for the thumbnails you can use something like:
BitmapImage Picture = new BitmapImage();
Picture.BeginInit();
Picture.UriSource = ... // your picture
Picture.DecodePixelWidth = ... //how big you want your pic
Picture.EndInit();
do you want to show all the images of the list at the same time? I believe you can use the grid and put a picture control in any cell of the grid, you can start with this approach, post your results and ask more specific questions once you have it at least partly done.