I want to show my custom control(eg: monthcalendar) as a drop-down (popup) window.
One option is to use ToolStripDropDown and ToolStripControlHost as the second example in msdn example.
My doubt is:
ToolStripDropDown should be used for ToolStrip items - is this correct or not?
Any other better options to achieve the above requirement?
If you have a simple control, it should be completely fine to use the ToolStripDropDown/ToolStripControlHost combination. More complex controls, however, have sizing, focus, and tab order issues that are difficult to correct. I would recommend that if your custom control has more than one "edit" type child control in it, you're probably better off creating a custom dialog and not trying to make it work in a dropdown.
Related
In LightSwitch, when I open the default modal, calling the AddAndEditNew_Execute method, I want to change properties of the controls inside the modal dialog.
For instance: I want to change a TextBox to "Multiline" or change AutoComplete FilterMode to "Contains".
How can I access to those controls in execution time?
I know I can add a custom modal, but I just want to change a small thing of it and I don't want to create a whole modal dialog just for this.
I'm always talking about Silverlight client.
Thanks in advance.
I'm afraid that the only way you can do what you want is:
with a custom modal window (if you want the window to be modal)
or a separate screen (if you don't need the window to be modal)
The properties of a default modal window can't be changed. There are no mechanisms to change the properties of any of the controls.
The only thing that you can do is to influence which properties get displayed in the default modal window, by checking/unchecking the Display By Default check-box in the table designer.
But as soon as you need to make changes to either the layout of the controls, or changing any control's properties, you need to create a custom modal window, or separate screen, & display then by calling them in custom code.
The reason for this is because the controls for the default modal window are generated by the LightSwitch run-time.
It's really just a matter of a balance between not having to do the work to create the window, & flexibility.
Default: Easy = Yes, Flexible = No
Custom: Easy = No, Flexible = Yes
I know it's not what you wanted to hear, but hopefully my explanation helps you to understand why you can't do it the way you first wanted to.
Can someone suggest the best way to achieve my goal?
So, I have a form with three buttons. What I want is, depending on what button is pressed on panel should be shown different controls (user control). I made this in a simple way: all are added from the beginning, I just make change to the visibility. But what would be nice is, if someone can suggest a more appropriate way, because there is no need to have objects created from beginning.
You can always create the appropriate UserControl, and add it to the Panel.Controls at runtime. This will allow you to create the control(s) as needed, instead of on initialization of your Form.
I would indeed create the controls at design time - if there's advantage no to dynamically create them. Why complicate matters?
If there are a number of controls I would put them all in a panel (within the panel you've already mentioned) so you're only changing the visibility of a single control (the panel) rather than each one within it.
When you press the appropriate button show the appropriate panel (and remember to hide the others in case you've previously shown them)
I'm developing a WPF application in C# and was thinking about implementing a custom UI element accross various windows.
I would like to have a minimized tray (only about 4px visible) that expands after clicking on an icon next to the tray. The expanded version would show all controls and would minimize when I click the icon again. I created a quick HTML concept to clarify things.
I know I could put a stackpanel and button in my application and making both of them move up when I click the button, but then I would need to duplicate the code a lot.
Though I'm experienced with C#, I'm fairly new to WPF interface development/templates, but I'm sure there has to be a way so I can use that UI element accross my application without needing to copy/paste a lot of lines of code in my form class file.
I hope someone can help me, or at least point me in the right direction.
There are three ways to customize your elements.
1 If you only need visual modifications you can use styles to change the appearance of the .net default controls. You can even override / extend the default templates.
2 If you want custom logic in a control you can create a custom control. The framework brings a lot of "primitives" to build upon. Examples are ContentControl or HeaderedContentControl. Say you want to build a custom expander control you can inherit your custom control from HeaderedContentControl which provides you with Header and Content properties and you just have to implement the toggling logic yourself.
CustomControls are a good choice if you want to build basic functionality which can be used throughout your application. They can be themed/styled depending on the use case, too (see 1).
3 If you want to compose different controls into one control you can create a UserControl. User controls are composed using XAML. Most top level controls are user controls driven by a view model.
Your case can be build using a Popup and ToggleButton or an Expander.
The decision depends on the desired behavior. If you want the opened panel to move following content down you need a expander. If you want a dropdown like functionality you need popup.
If you use a popup just bind the IsPopupOpen Property to IsChecked of the ToggleButton and set PopupStaysOpen = false to wire the button to your popup.
If you use an expander control you should create a style which can be applied to all equal expanders in your application to minimize the required XAML in each view.
How about using Expander Control?
There's a control called an Expander that is perfect for this. You'll have to style it to look like you want, however it has the functionality you want built-in.
I would like to develop a custom Toolstrip control. The control would be like a ToolStrip but with the following features :
The textbox would be proceeded by a label
The textbox would have two buttons after it.
I guess to implement this then a user drawn control would be required. Does anyone know of any resources available on the web to get me started on this.
First you should compose your usercontrol with label, textbox and buttons, exposing all the necessary Properties.
Here's a MSDN WalkThrough for UserControls creation
Then, use this answer (or this MSDN example) to create the custom ToolStripItem, just replace the TrackBar with you custom control.
P.S.
If you don't want to create a ToolStripItem, but just a popup showing your custom control, you can use this other example, replacing the ListBox with your control.
if one part of one form of our app has many views - let's say depending on a radio button selection some where else on that form - then sometimes using a TabControl with some tabPages can be easy and helpful to show different views based on that selection.
so I still would like to have that "multiple views" functionality but I do not want to use a TabPage.... what would be the best replacement for that?
As far as I know, you'll have to code such a control yourself if you desire a lot of functionality. For regular operations, however, you can use this control I found on CodeProject: Multipane Control.
You could just have a Panel or something to define the area and then you could create one User control for each "view" that you want and then when the user selects a different radio button you just shows/hides the relevant user controls inside that Panel.
Or if the "views" are very simple, maybe the User controls would be overkill and you could just have a GroupBox for each view that you show/hide, but that can quickly create messy code if there are lots of event handlers etc.