In the SciChart tutorials there are only instructions how to add a LabelProvider with hardcoded Label texts, that can be switched on different values (https://www.scichart.com/example/wpf-chart-example-stacked-column-side-by-side/). Is there any way to programmaticaly add and handle axis labels?
UPD: Idea is to mark columns with different labels, so that every column has a text label instead of numeric value on the main axis.
Solution is pretty obvious. To dynamically handle labels from ViewModel, you can bind a LabelProvider itself.
Related
Just recently started WPF and well into the run before I can walk stage.
I have made a custom control that I need for one of my projects, and it looks almost exactly as I want. It currently looks like this:
whereas I need to add a scale to the horizontal and vertical sides, with a mark and a number of how many cells we are at, skipping a predefined number which should look roughly like this:
The model that provides the data for the control has the data, the size of each cell (and thus the overall size), all the label text, and a step value for the X and Y control.
The control is a grid with the title in the top row, the y title, space for the numbers, the control in the second row and the space for the X control in the next and the title of the x axis in the last.
If I was doing windows forms I would just draw in manually and it would be pretty simple, but I would like to learn this properly.
After a lot of googling, I can't find a way of doing this easily in XAML, so I assume I have to do a custom control on a canvas, or is there an obvious way that my inexperience with WPF is missing?
There is nothing out to the box but there is a control you can work off of to get what you need. Investigate modifying the TickBar.
An initial search turned up How to use string values in place of ticks on WPF Tickbar?.
I am working on an app to show sort of a time table.
Let's say I have a 2D array of items and I would like to display them in a 2D grid with both line and column headings (dayOfWeek x time).
I also need to be able to change background color of each cell depending on the contents (for example if the items name at position [x,y] is empty, I want to display cell at that position with red background.
What I can do is arrange a bunch of textboxes to form a table (because I have a fixed array size). However, this approach seems a bit too complicated and I could imagine there is some easier way to do this. ListView maybe?
So what I am asking is this: What is the best tool, or way in windows forms I should use for my problem? I am not looking for a finished solution, just a little tip / guidence. Thanks in advance!
You can use a ListView adding the columns with myListView.Columns.Add("whatever", width) and you can change the cell color with myListView.ForeColor = redColor. Being redColor a Color type.
The Windows.Forms Listview in details mode should be able to do what you want.
I want a grid in my page to have a single column in portrait mode and have two columns in Landscape mode. Some of the content should move to the second column when the device is Landscape. I've tried to do this but couldn't.
I'm doing everything from code behind. Generating the grid, adding children etc. When Orientation changes, I destroy the current layout and create a new one. The problem with this approach is, any entered data will be gone. It's a huge code and not possible to put here. I want this layout change to happen automatically. So, any data that is entered is preserved after the orientation change.
Any help would be appreciated.
The trick is to have one grid that accommodates both states. You can use VisualStates to assign different Grid.Row, Grid.Column, Grid.RowSpan and Grid.ColumnSpan values to controls. This is done using Blend and is declarative in XAML. you give each state a name. In the code you detect size change of the window to trigger the different states using the VisualStateManager.
You can also do this without VisualStates. In that case in the event handler of the SizeChanged you have to set the appropriate values for all the controls yourself.
In Windows 10 UWP it got much simpler using RelativePanel. You can position controls in a more flexible way then with grids.
Martin
I am creating a stacked column graph but am currently limited by the lack of label positioning for each series. There are not any custom properties which relate to alignment of label positioning, is there some other way to offset labels or align them for stacked charts?
By creating a dummy series and manually setting each label value you can reposition a stacked columns labels to either the top or bottom of the stack. It is limited, and certainly not what I would like, but it is the best I have found so far.
While the control used is different the best example of the concept I have found is here:
total value of each column in a stacked column
Check out my blog post for more details and a better method of handling this:
http://jeremeguenther.blogspot.com/2015/02/overlapping-columns-in-microsoft-aspnet.html
last paragraph from the msdn : link
you might wanna check out the SmartLabelStyle altough I've never used it with column chart type. link
I need to build a WPF control that looks somehow similar to this:
alt text http://img251.imageshack.us/img251/6857/circle.png
Where each color should be clickable and resizable (or selectable).
This control will be used to set modes on the hours of a day.
I've thought about making 24 buttons that would be arranged in a circle:
alt text http://img684.imageshack.us/img684/2184/buttonsk.png
Another idea was to draw a complete circle and calculate user mouse click's position for the selection and draw several circles to represent the data.
Any other/better ideas on how to build this?
(please excuse my poor drawing).
I think you would get odd edge-effects with multiple overlapping or touching controls. So I would make a single custom control to do this. It would convert the mouse position on button down to a slice, and then do the appropriate action.
With a single control, you could also come up with a rational way of dealing with keyboard input and for showing selection and allowing for multi-select behavior.
It sounds like you want a customized ListBox (multiple items that are selectable/clickable). For the layout you would want to use some type of RadialPanel as the ItemsPanel. You probably also need to change the ItemContainerStyle to make your ListBoxItems look like what you have above, probably with some triggers to change colors based on selection state. Depending on what behavior you need from your items you may need to create custom ListBox/ListBoxItem derived custom controls but in a lot of cases the built-in behavior will get you a long way. To reuse it as a single unit you could wrap up the ListBox with its 24 hour items and customized templates in a UserControl and expose the selection data in whatever form you need as a Dependency Property (like an IEnumerable of the data items representing the selected hours).
Does that help you get started?