需要一些关于WPF控件的帮助 [英] Need some help regarding WPF controls

查看:111
本文介绍了需要一些关于WPF控件的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个网络发现工具,它将发现网络中的所有设备。



在网络中发现所有设备IP后,我想要使用WPF为用户显示它们。



关于哪种控件最能代表具有小图像的设备的任何想法。



注意:我需要代表大约160个设备。



提前致谢。

解决方案

有许多不同的方法可以做到这一点。这取决于您所追求的用户体验。



您将要选择两种控件类型。第一个是容器或项目控件,例如组合框,网格,堆栈面板等。这将设置项目的布局方式(在垂直列表中,在行中,在可滚动列表中,在组合框中)等等)。

第二种控件类型是代表每个设备的控件。如果您真的在显示图像(例如PNG),则图像(控件)会适合您。或者,您可以使用路径,文本块等...



我会花一些时间玩xaml来感受不同类型的控件提供的内容,然后回到你的项目:)


一个带有gridview的Listview将是我的选择:

http://msdn.microsoft.com/en-us/library/ms752213.aspx [ ^ ]



或者你可以也可以使用DataGridView。


理想情况下,您可以使用带有自定义数据窗口的列表框,其中datatemplate的一部分是图像而另一部分是文本块...





 <   ListBox     x:name   =  netDevices    itemssource   =  {Binding NetworkItems ...} >  
< ListBox.ItemTemplate >
< DataTemplate >
< StackPanel 方向 = 水平 >
< 图像 source = {Binding ImageIcon} / >
< TextBlock text = {Binding DeviceName} / >
< / StackPanel >
< < span class =code-leadattribute> / DataTemplate >
< / ListBox.ItemTemplate >
< / Listbox >


I am developing a Network discovery tool, which will discover all devices in the network.

After discovering all device IP''s with in the network, i want to display them for the user using WPF.

Any idea regarding which control will be best to represent those devices with small images.

Note: i need to represent around 160 devices.

Thanks in advance.

解决方案

There are many, many different ways you could do this. It depends on the user experience you are after.

You are going to want to pick two control types. The first one will be a container or items control, such as a combo box, grid, stackpanel, etc. This will set how your items are laid out (in a vertical list, in a row, in a scrollable list, in a combobox etc).
The second control type will be the controls that represent each device. If you are literally showing an image (such as a PNG), an Image (control) would suit you. Alternately, you could use a Path, textblock etc...

I would spend some time playing with xaml to get a feel for what the different types of controls offer, then come back to your project :)


Well a Listview with a gridview would be my choise:
http://msdn.microsoft.com/en-us/library/ms752213.aspx[^]

Or you could use a DataGridView also.


Ideally you could use a listbox with a custom datatemplate in which one part of the datatemplate is an image and the other a textblock...


<ListBox x:name="netDevices" itemssource="{Binding NetworkItems...}">
   <ListBox.ItemTemplate>
      <DataTemplate>
         <StackPanel Orientation="Horizontal">
             <Image source="{Binding ImageIcon}" />
             <TextBlock text="{Binding DeviceName}"/>
        </StackPanel>
     </DataTemplate>
   </ListBox.ItemTemplate>
</Listbox>


这篇关于需要一些关于WPF控件的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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