I have a textbox with a search icon next to it inside of a dockpanel that I use in every page of mine. I plan on hooking up the click of the search icon to a command and on each page it brings up the same popup with a listview, whose contents vary from page to page based on the viewmodel binding.
I would like to be able to centralize this text+search control so I can re-use the control and include it in each with a line or 2 of code - the inclusion such as and the line for binding to a different search method (if necessary).
What is the best way to do this? Create a custom or use some kind of template approach?
Please advise and if possible, describe the design and provide an example.
Thanks in advance
If in my wpf application there are multiple grids and a dragable user control.Can anyone suggest code that could return different grid id every time the control is dragged over different grids.
You can use Mouse.DirectlyOver then go up the visual tree to find the first Grid up the tree.
Mouse.DirectlyOver returns the IInputElement that is under the mouse at the time you check the property.
You can walk up the visual tree using a method described in this SO question
Edit: I found the SO question about visual tree walking i was thinking about. (much better than the first link IMHO).
Before I begin, I'm no SL or WPF master, so I need some guidance. What I have is a List<CustomObject> . I then have a view that I can bind a "CustomObject" to and have all the data displayed. Now to keep intack with the Metro guidelines and Navigation guidelines, I want to be able to use the SL Control Toolkit Gesture Service to detect a flick (this part is done and working). When I flick left, it binds current list position -1 when I flick right is binds current list position + 1.
Now, I need to make it pretty. I'd like it to behave similar to the pivot control, as when I hold down, it moves the grid to the left and when the full flick is created it slides away to the left or right and loads the the next item.
These lists can have 100's of items, so dynamically adding them to a Pivot control isn't an option.
I know I have to capture the OnDelta and start moving the grid, but I'm really trying to find a sample that's similar to what I'm looking for to give me all the peices. There used to be a few custom implementations of the Pivot and Panorama control but I can't find them.
Any ideas that can point me to the right place?
Thanks!
Because you need to create multiple instances of whatever displays your CustomObject I would consider using a Pivot control with three items in it. The three items should be the current item and the ones either side of it.
As the user navigates between items update the DataContext/Binding of the other items so they reflect the itesm next to the one currently displayed. (You'll only need to set one at a time.)
I've used this technique successfully in apps where each page wasn't excessively complicated to load. (When it was there was a lag when navigating quickly between items.)
I was thinking of ways to implement a generic View search. What I mean here is say a Window has many controls (including usercontrols,customcontrols, etc). I want to implement a generic search box on the top of window which searches any Text in the window and highlight them.
I wanted to know is there a generic way of doing this or has anyone tried such UI based search.
I was searching through internet and found some nice links like below::
http://khason.net/blog/search-and-highlight-any-text-on-wpf-rendered-page/ which says search and highlight any Text in WPF rendered page but it doesnt work when there are lot of UserControls and CustomControls.
I myself did some research and thought of going through the VisualTree,LogicalTree, etc but I did not find them satisfactory.
Some say do it using attached behaviors or by data binding but that also did not help me. Because even if i achieved search using this technique, the problem is highlighting. Say there are 4 TextBoxes having different background colors and I highlight background to Yellow when Text is found, I have no way of removing the highlighting when Text is not found because I don't know the previous background color of TextBox.
Ok , enough of my thoughts. I would like to simply accept I am going nowhere in my thoughts. So people I want some guidance in implementing UI search. Also if you people can tell me how I can make it generic, it will be useful!!
In order to make a convenient UI for an .Net 2.0 Winforms application I am working on, I have need for a control that I'm pretty sure goes beyond the "out of the box" behavior of any standard control. A mock-up of what I'm trying to achieve follows:
Mock up http://www.claware.com/images/temp/mockup.png
Essentially, this part of the application attempts to parse words into syllables from tribal languages (no dictionary to refer to; any and all unicode characters are possible.) By the time the user gets this far, he has already defined the vowels / consonants in his language and some other configuration. There is then an iterative process of (1) the application guesses which syllables exist in the language based on some rules, (2) the user refines the guesses, selecting the correct parsings or manually parsing a word, (3) the application "learns" from the user's feedback and makes smarter guesses, (4) repeat until the data is "good enough" to move on.
The control needs to present each word (the grey headers), then all the syllable break guesses (the white areas with dots separating the parts of words.) There is also a way to manually enter a parsing, which will display a text area and save button (at the bottom of the mockup.) When the user hovers over a guess, the background changes and "accept / reject" buttons appear. Clicking on the accept, or entering a manual parsing, removes the entire word from the list. Clicking the reject button removes just that item.
I'm by no means 100% sold on the formatting I have above, but I think you can get a general idea of the types of formatting and functional control I need. The control will also scroll vertically--there may be thousands of words initially.
My question for you experienced WinForms developers is: where to start? I would really, really like to stay within the .Net core framework and extend an existing control as opposed to a third-party control. (At the risk of starting a religious war: yes, I suffer from NIH-syndrome, but it's a conscious decision based on a lot of quick-fix solutions but long-term problems with 3rd party controls.) Where can I get the most "bang for my bucK" and the least reinventing the wheel? ListView? ListBox? ScrollableControl? Do I need to go all the way back to Control and paint everything manually? I appreciate any help that could be provided!
[Edit] Thanks everyone for the ideas. It seems like the most elegant solution for my purposes is to create a custom control consisting of a FlowLayoutPanel and a VScrollBar. The FlowLayoutPanel can contain instances of the custom controls used for each word. But the FlowLayoutPanel is virtual, i.e. it only contains those instances which are visible (and some "just out of scroll"). The VScrollBar events determine what needs to be loaded. A bit of code to write, but isn't too bad and seems to work well.
I would look at the TableLayoutPanel and FlowLayoutPanel controls. These will let you organize a series of controls with moderate ease in a vertical fashion. I would then create a UserControl that consists of a label and 2 buttons. The UserControl will expose properties like Text and events that are exposed for the button clicks.. For each entry in the list, you will create an instance of the UserControl, assign the text value, and handle the click events. The instance will be placed in the Table/Flow panel in the correct order. Both of those layout panels do allow for inserting items between other items so you can add/remove items from the list dynamically.
Edit:
Given the length of what you are trying to render, I would consider using the DataGridView and do some custom rendering to make it perform how you want it to work. Using the rendering events of the DGV you can merge columns, change background colors (like highlighting the dark gray lines), turn on/off the buttons, and handle changing the grid into edit mode for your rows to allow modification or inserting of new values. This method would easily handle large datasets and you could bind directly to them very easily.
Well, this certainly looks like a candidate for a custom component that you should be creating yourself. You can create this using standard .Net drawing commands along with a text-box, and a regular button control.
Now you want to find out where to start.
Create a Windows Forms Control Library project.
Drop in the textbox and the button control.
The panel drawing code should preferably be done by code. This can be done using the regular GDI+ commands.
Edit:
Here's another idea, and one that I've practically used in my own project with great success.
You could use a web-browser control in the app, and show your data as html. You could update the source of the web-browser control based on the input in the textbox, and clicking on the links in the web browser control will give you the event that you can trap to do some action. Your CSS will work.
I used this technique to build the 'desktop' in an app I made called 'Correct Accounting Software'. People loved the desktop so much that it is one of the best loved features of the app.
Here's how I would do it:
Create a custom control. In this custom control, have a ListBox atop a LinkButton, and when the LinkButton is clicked you can make it give way to a TextBox. The ListBoxes will have the top row unselectable... you can probably get the rest from there. When you get your list of words, fill a Scrollable of some kind with one control for each word:
(foreach String word in words){
myScrollable.add(new MyComponent(word));
}
From there, I'm not sure what you want to do with the boxes or the data, but that's my initial idea on the UI setup.
Use the WebBrowser control and generate the HTML markup into it using DocumentStream or DocumentText.