If I have a simple WPF app. This app runs some scripts to process data and I want to display some of that data (statistics) on the screen. What is the best control to use (text box, richtextbox, etc)?
I want the control to show data/update data as the script is running in the background.
Start by doing a little sketch on a paper how your form will look like. This helps you answer your own question.
Displaying statistic depends on the way you want to display them:
You can use a DataGrid when you have to display table form statistic results.
You can use TextBlock when you have to display final results (kind of Aggregations, Sums, Averages etc)
The most common whay to display statistics is by using Chart control
At any time, you can refer to the Microsoft's UX Guide
Related
We have images created off a a high resolution scanner for showing defects on glass products. Our C# application is used by clients to manage defects. Many customers are having difficulties translating the image properties like actual length provided. I am working with a base image with a canvas on top. I also have a grid with a list of properties which when selected, I want to show a visual on how to translate the selection by say, drawing a line on the canvas in a manner that depicts the translation.
It turns out that the requirement was misconstrued and what was needed was creating simulations on separate images that I had to create and load. Next time I will try to think outside the box.
I'm trying to make a custom Slider inside a UWP app, which should look and function somewhat like the scroll in Windows 10 built-in Photos application:
There are two main features which exist in this screenshot, yet I couldn't find a way to implement myself:
All the positions within the same range in the slider/scrollbar, should have the same tooltip value. In the screenshot example, you can see that all photos within a specific range of the slider (between two ticks) show the same tooltip, which is the name of that month.
The gaps between the ticks aren't always the same. In the screenshot example, they rely on the amount of photos taken in each month, relatively to the total amount of photos.
I have found that in WPF, it's quite easy and straight-forward to set custom values for the ticks on a Slider (see here), but in UWP these attributes seem to be gone. Also, couldn't find anything about it in the official docs. I did notice there's a UWP control called TickBar, but couldn't find any examples in order to understand if it's relevant for my question.
Am I missing something, or is it really not possible to achieve such UX without making my own fully-custom UI Control?
It's not a Slider control. If you want to make such a control, you would have to do a lot of customization. You might need to make a UserControl. This UserControl nees some basic UWP controls to make it look like the MS Photos app.
For example, you might need an custom ItemsControl(the StaggeredPanel looks very similar) to manage the layout of pictures in the page, and customize the ScrollBar, use two ItemsControls to show the Year/Month on the right side. You also need some label to show the text when you pointer move on the ScrollBar, the label might be the TextBlock control etc. You also might need some animations.
Anyway, to make such a control, you need a lot of basic knowledge and do a lot of customization. It's complex. You could submit a Feature Request on WPDev UserVoice.
I refer to mainly tabular forms, with columns of labels and corresponding input controls. In HTML we can use <ul>, <ol>, or my favourite, <dl>, to couple labels and inputs making them integral input devices. In WPF I can find (I am very new) nothing but a Grid control with two columns, one for label, and one for input. Often several of these monstrosities are needed to complete a form layout.
Is there no integral functionality in WPF for form layout? It was designed for Windows UI windows, a great, great many of which are simple forms, not fancy graphics or animations.
Put your controls in a Grid container. That should allow you the tabular layout you're looking for.
There are several containers at your disposal. Here is a list explaining each one. The Grid container is what you're probably interested in. You're able to specify RowDefintions and ColumnDefinitions to construct a grid to place other controls.
I want to display slider like control with Database values, Like below image.
Is there any control available for this? and How can I make this,
Database values will between 1-100. I have no idea from where to start
You can try learning about System.drawing and make your own control, i have done this in the past when i made a custom progress bar, I used this tutorial on YouTube and it might help you as well.
Also with making your own control you can change anything, get creative.
I think you need to use Timeline Chart ,
Here is Google Timeline Chart Example :)
I'm still getting to grips with C Sharp and .NET and I am working on an application to display data being continually read from a USB device. I have all the USB code working and it is receiving the data updates every 5ms. The data consists of a set of sensor values for a number of units, say 50 units with 12 sensors per unit.
Currently I am using a ListBox object to display 50 rows of data. I'm setting the listbox mode to OwnerDrawFixed and my datasource to my data array of objects that represents the data read from the USB device (one object per row of the ListBox) and I'm using the DrawItem event to actually graphically draw each row of the list box as requested by the listbox (I'm doing it this way to enable text colouring, formatting, tidy layout etc).
In order to get the ListBox to refresh the data being displayed I'm calling periodically calling Invalidate to force it to redraw, but this is horrendously slow, and flicker unacceptably even at low frequecies such as 1 second updates never mind getting anywhere near the 5ms refresh of the sensors.
Can anyone suggest a better approach to updating the data on screen, perhaps one where I'm not drawing everything everytime or perhaps a way to tell the ListBox to only redraw a single row perhaps if the data on that row has changed?
I'm not tied to a ListBox in anyway, it's just my unfamiliarity with the .Net framework - perhaps the best solution might be to render everything to a bitmap and then blit it to the screen in a single action.
I've already read a similar question but the suggestions in there didn't really help...
c# - fast ListBox data update
Any alternative suggestions from experienced .net developers greatly appreciated...
Inherit the ListBox control and enable double-buffering is, I think, your best bet. I don't know how the ListBox paints but that should reduce flicker.
(If that doesn't work, a hack is to invalidate only a tiny rectangle on the corner and hope it paints properly. That most likely won't work with the original set of controls, though.)
It's very difficult to make a recommendation without knowing what you are doing. You might explain what your "data", "sensor values" and "units" are. In general, graphics are better for showing large data sets than vast lists of numbers.
If this is some kind of transient data, like sound intensity, you might consider a VU-meter kind of display, like in a music player.
If you are trying to track trends or changes, consider a sparkline or graph.
If you are trying to show correlations between data, consider a spectrum or XY graph.
In WPF you can fill ListBox at the beginig and after what just send data to layout acynchronosly.
If its posible use WPF you should try. Code is triviale when you have constant emount of data items.
For those who are interested in the solution that worked for me both solidly flicker free and fast.
I simply use a Panel control to represent my table in the design view, then in my code I have a method which is triggered by a timer every 1ms (though in reality I can't seem to get it faster than every 16ms - which I guess is probably linked to the 60hz vsync refresh of the monitor because I'm doing a graphical blit).
I grab the bounds of the panel, create a bitmap of matching size, draw my data to the bitmap using the various graphics commands (such as DrawString) then I blit the resulting bitmap to the panel control. This works well if I then subsequently resize the window as the panel is resized and my bitmap is accordingly resized.
This also works fast, and in reality is no more work than the previous slow/flickery solution using a list control, however it is to be noted that there is not support for selecting rows etc (as this app was only using a ListBox to display data).
I'm now seriously considering mini techs suggestion for future listbox work as this work around works fantastically well, and subclassing the ListBox (rather than basing it on a Panel control) would allow me to inherit some of the row selection stuff etc.
Thanks for all the suggestions,
Rich