Click here to Skip to main content
15,943,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a suggestion. In my program the user select a file and different graphs are drawn as a output for that file. I want the user to give the choice of selecting the graph which graph he wants to see. Suppose he only wants to see 2 graphs,then he will check 2 checkboxes. Everytime he will check a new checkbox a new graph will be drawn.when he will uncheck a particular checkbox that graph will be vanished from the screen.
Should I only use a StackPanel and inside it different checkboxes? or i should use a listBox.
I am not sure which option is better in my case. Could you please help me.

What I have tried:

I have not implemented anything so far. I just need to know what should I use.
Updated 18-Oct-18 2:13am
j snooze 17-Oct-18 17:23pm    
Really depends on the data you're working with. If the number of graphs are static and only a couple, checkboxes are probably fine, but if the list of graphs is dynamic and could be many, I would lean toward listbox if that helps. Too many checkboxes would make the screen way too busy. Don't know if that helps, but I'm basing off of the small bit of info given. Keep in mind its only opinion. Any interface thats intuitive and easy to use for users is ultimately what you want.
hamid18 18-Oct-18 4:39am    
The graphs are dynamic and they are many in numbers. I am new in programming. So I will take your suggestion as a first step towards the solution.

1 solution

General description of how to proceed:

In your XAML create a grid with two columns.

Load the data and create your graph controls in an observablecollection in code-behind. I would create a new class, inherited from your graph control, that adds a title property.

Set visibility of the graph controls to collapsed.

Create a stackpanel or gridview in code-behind (or other suitable container) in code behind, and add all of the graph controls as children of the container. Don't forget to set the container's Grid.Column property to 1.

Create a CheckListbox in XAML that binds to the Observable collection of graphs, and set the listbox items t0 display the title, and bind the checkbox to the Visibility property of the graph control.

Write a converter that will toggle the visibility property between Visible and Collapsed, depending on the state of the checkbox.
Share this answer
hamid18 18-Oct-18 17:48pm    
Thank you very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900