|
4 | 4 | [](https://docs.devexpress.com/GeneralInformation/403183)
|
5 | 5 | [](#does-this-example-address-your-development-requirementsobjectives)
|
6 | 6 | <!-- default badges end -->
|
7 |
| -<!-- default file list --> |
8 |
| -*Files to look at*: |
| 7 | + |
| 8 | +# WPF SlideView – Display a Horizontal List of Cards with Swipe Navigation |
| 9 | + |
| 10 | +This example uses the [`SlideView`](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView) control to display a scrollable horizontal list of items. Each item is rendered as a content card with user-defined templates. |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +Use the [`SlideView`](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView) control when you need to: |
| 15 | + |
| 16 | +- Display detailed information for data items in a focused, single-item view. |
| 17 | +- Create a modern, user-friendly interface with swipe-style navigation. |
| 18 | + |
| 19 | +## Implementation Details |
| 20 | + |
| 21 | +### Data Structure |
| 22 | + |
| 23 | +The data source, which contains a list of `Employee` objects, is exposed by the `EmployeesData` view model through the `DataSource` property. The `Employee` class exposes employee-related properties (such as `FullName`, `Photo`, `JobTitle`, `EmailAddress`, and `City`). Images are stored as byte arrays and converted to BitmapImage objects at runtime. |
| 24 | + |
| 25 | +```csharp |
| 26 | +public class Employee { |
| 27 | + public string FirstName { get; set; } |
| 28 | + public string LastName { get; set; } |
| 29 | + public string FullName => FirstName + " " + LastName; |
| 30 | + public string JobTitle { get; set; } |
| 31 | + public string EmailAddress { get; set; } |
| 32 | + public string City { get; set; } |
| 33 | + public byte[] ImageData { get; set; } |
| 34 | + |
| 35 | + [XmlIgnore] |
| 36 | + public BitmapImage Photo => imageSource ??= LoadImage(); |
| 37 | + |
| 38 | + BitmapImage LoadImage() { |
| 39 | + var stream = new MemoryStream(ImageData); |
| 40 | + var image = new BitmapImage(); |
| 41 | + image.BeginInit(); |
| 42 | + image.StreamSource = stream; |
| 43 | + image.EndInit(); |
| 44 | + return image; |
| 45 | + } |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +### Templates |
| 50 | + |
| 51 | +The following code example defines two templates: |
| 52 | + |
| 53 | +* [`ItemHeaderTemplate`](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView.ItemHeaderTemplate) displays the employee’s first name. |
| 54 | +* [`ItemContentTemplate`](https://docs.devexpress.com/WPF/DevExpress.Xpf.Docking.LayoutGroup.ItemContentTemplate) displays detailed information, including photo, contact details, and job data. |
| 55 | + |
| 56 | +```xaml |
| 57 | +<DataTemplate x:Key="ItemHeaderTemplate"> |
| 58 | + <TextBlock Text="{Binding FirstName}" /> |
| 59 | +</DataTemplate> |
| 60 | + |
| 61 | +<DataTemplate x:Key="ItemContentTemplate"> |
| 62 | + <Grid> |
| 63 | + <!-- Photo, FullName, JobTitle, etc. --> |
| 64 | + </Grid> |
| 65 | +</DataTemplate> |
| 66 | +``` |
| 67 | + |
| 68 | +### Slide View Configuration |
| 69 | + |
| 70 | +```xaml |
| 71 | +<dxwui:SlideView |
| 72 | + Header="Slide View" |
| 73 | + ItemsSource="{Binding DataSource}" |
| 74 | + ItemHeaderTemplate="{StaticResource ItemHeaderTemplate}" |
| 75 | + ItemTemplate="{StaticResource ItemContentTemplate}" /> |
| 76 | +``` |
| 77 | + |
| 78 | +## Files to Review |
9 | 79 |
|
10 | 80 | * [DataStorage.cs](./CS/SlideViewSample/DataStorage.cs)
|
11 |
| -* **[MainWindow.xaml](./CS/SlideViewSample/MainWindow.xaml)** |
12 |
| -<!-- default file list end --> |
13 |
| -# WPF SlideView - Display a horizontal list of items with slide navigation |
| 81 | +* [MainWindow.xaml](./CS/SlideViewSample/MainWindow.xaml) |
14 | 82 |
|
| 83 | +## Documentation |
15 | 84 |
|
16 |
| -<p>This example demonstrates how to create a SlideView, bind it to data and use templates to visualize its items. </p> |
| 85 | +* [SlideView](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView) |
| 86 | +* [SlideViewItem](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideViewItem) |
| 87 | +* [ItemHeaderTemplate](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView.ItemHeaderTemplate) |
| 88 | +* [ItemContentTemplate](https://docs.devexpress.com/WPF/DevExpress.Xpf.WindowsUI.SlideView.ItemHeaderTemplate) |
| 89 | +* [Slide View](https://docs.devexpress.com/WPF/15020/controls-and-libraries/windows-modern-ui/content-containers/slide-view) |
17 | 90 |
|
18 |
| -<br/> |
| 91 | +## More Examples |
19 | 92 |
|
| 93 | +* [WPF Accordion Control – Bind to Hierarchical Data Structure](https://github.com/DevExpress-Examples/wpf-accordion-bind-to-hierarchical-data-structure) |
| 94 | +* [WPF MVVM Framework – Use View Models Generated at Compile Time](https://github.com/DevExpress-Examples/wpf-mvvm-framework-view-model-generator) |
| 95 | +* [WPF Dock Layout Manager - Populate a DockLayoutManager LayoutGroup with the ViewModels Collection](https://github.com/DevExpress-Examples/wpf-docklayoutmanager-display-viewmodels-collection-in-layoutgroup) |
| 96 | +* [WPF Bars – Create a Container for BarItem Links](https://github.com/DevExpress-Examples/wpf-bars-create-baritem-link-container) |
| 97 | +* [WPF PDF Viewer – Customize the Integrated Bar's Commands](https://github.com/DevExpress-Examples/wpf-pdf-viewer-customize-bar-manager) |
20 | 98 |
|
21 | 99 | <!-- feedback -->
|
22 |
| -## Does this example address your development requirements/objectives? |
23 |
| - |
24 |
| -[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=create-wpf-slide-view&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=create-wpf-slide-view&~~~was_helpful=no) |
25 |
| - |
| 100 | +## Does this example address your development requirements/objectives? |
| 101 | + |
| 102 | +[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=create-wpf-slide-view&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=create-wpf-slide-view&~~~was_helpful=no) |
| 103 | + |
26 | 104 | (you will be redirected to DevExpress.com to submit your response)
|
27 | 105 | <!-- feedback end -->
|
0 commit comments