图像滑块/滑块显示 [英] Image Slider / Slider Show

查看:73
本文介绍了图像滑块/滑块显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起伙计......我刚刚开始学习XAML / WPF / C#。


我正在尝试为电影桌面应用程序开发UI,而我我想知道如何创建图片滑块,例如,每1秒显示一张新图片(可能左右箭头,允许用户可视化
预期图片),正如我们通常在任何一个上找到的那样网站。



问候

解决方案

WPF不是网络所以"就像你通常在任何网站上找到的那样"一切都非常好,但又不同。


此外,这是一个相当广泛的问题,并不完全是人们可能称之为具体的问题 - 这意味着如果我为你写了一些东西它可能赢了无论如何都不要做你想做的事。


当你在wpf UI中处理大量事情时,你的候选人名单的顶部应该是某种物品控制。


这些东西收集作为itemssource的东西,然后可以将它们模板化为UI。


通过绑定和mvvm模式来呈现集合

p>

喜欢 


https://social.technet.microsoft.com/wiki/contents/articles/31915.wpf-mvvm-step-by- step-1.aspx


https://social.technet.microsoft.com/wiki/contents/articles/32164.wpf-mvvm-step-by-step-2.aspx


如果您要找到列表框的模板,那么您会发现它有一个stackpanel作为itemspanel。这就是你通常所期望的所有行。


也许你希望你的图片水平滚动。


stackpanel有一个方向属性你可以设置这样做。


喜欢

< ListBox> 
< ListBox.ItemsPanel>
< ItemsPanelTemplate>
< VirtualizingStackPanel IsItemsHost =" True"取向= QUOT;水平" />
< / ItemsPanelTemplate>
< /ListBox.ItemsPanel>

您可能想要一些比每张图片更漂亮的东西,但是您使用ListBox.ItemTemplate对每个项目进行模板化。


至少你需要在那里进行图像控制并绑定它的来源。


这可以绑定到你在该边界提供的视图模型中公开的公共属性observablecollection。


然后您可以手动水平滑动图片。


因为该面板是虚拟化的,所以你可以拥有一个巨大的列表图片,一次只有一些内存。


然后你可以设置该集合同步并在列表中上下移动当前。添加一个将所选项目置于视图中的行为,然后您可以来回移动列表。


在列表框上

 IsSynchronizedWithCurrentItem =" True" 

列表框滚动浏览行为


https://stackoverflow.com / questions / 33597483 / wpf-mvvm-scrollintoview


如果你想自动化你可以使用dispatchertimer。


如果你想要按钮任何一方在列表框中你可以添加按钮,重新模板列表框......然后......让它适合你喜欢的工作。




sorry guys...I've just started learning XAML/WPF/C#.

I am currently trying to develop an UI for a cinema desktop application, and I was wondering how I can create pictures slider that for instance, a new picture is displayed every 1 second (maybe with the left and right arrows that allow the user to visualise the intended picture) as we usually find on any and every website.

regards

解决方案

WPF isn't web so "like you usually find on any website" is all very well and good... but different.

Also, this is quite a broad question and not exactly what one might call specific - meaning if I write something for you it probably won't do what you want anyhow.

When you're working with a bunch of things in wpf UI then the top of your list of candidates should be some sort of itemscontrol.

These take a collection of stuff in as itemssource and can then template those into UI.

Presenting a collection is usually done via binding and the mvvm pattern

Like 

https://social.technet.microsoft.com/wiki/contents/articles/31915.wpf-mvvm-step-by-step-1.aspx

https://social.technet.microsoft.com/wiki/contents/articles/32164.wpf-mvvm-step-by-step-2.aspx

If you were to go find the template for a listbox then you'd find it has a stackpanel as itemspanel. This is the thing holds all the rows you'd usually expect.

Maybe you want your pictures scrolling horizontal.

A stackpanel has an orientation property you can set to make that happen.

Like

<ListBox>
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>

You probably want something fancier than just a picture each but you template each item using ListBox.ItemTemplate.

As a minimum you'd want an image control in there and bind it's source.

That could bind to a public property exposed from a viewmodel you supply in that bound observablecollection.

You then have a load of pictures you can manually slide horizontally.

Because that panel is virtualising, you could have a HUGE list of pictures and only a few will be in memory at a time.

You could then set that collection to synchronize and move current up and down the list. Add a behaviour that brings the selected item into view and you could then move the list back and forth.

On you listbox

IsSynchronizedWithCurrentItem="True"

Listbox scrollintoview behaviour

https://stackoverflow.com/questions/33597483/wpf-mvvm-scrollintoview

If you wanted to automate that you could use a dispatchertimer.

If you wanted buttons either side of the listbox you could add buttons, retemplate the listbox and... well... make it work however you like.


这篇关于图像滑块/滑块显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆