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.
Related
I am not using anything other than a simple WPF application project in visual studio. I've implemented an mvvm application.
I want to display a list of content changes made by a user. I have a main window view model and it currently just builds a strings with changes. I have objects that I can reuse to display their properties (the content).
Currently, I use a MessageBoxResult to show a really long string with the changes. This is a terrible design (I know), but I couldn't really find an answer to what class a regular wpf project has that would allow me to achieve what I want.
I know there is a popup class I can use. In practice, which is better-- another view model for the dialog, or a popup?
Can anyone provide a simple example of one of the two approaches?
Thank you in advance for your response.
What I've done in the past is have a simple Border control, and inside of a TextBlock and whatever Button controls I need. I bind the TextBlock.Text to a public string property named "MessageBoxMessage" which calls OnPropertyChanged(). I bind the Command of each Button to a separate public ICommand which specifies what action to take in the view model when the button is clicked. I then bind the visibility of the Border control - which contains all of the other controls I mentioned - to a Visibility property.
When I want to show a dialog, I set the MessageBoxMessage to the message I want to show, makes sure the commands are set properly, and then set the Visibility on the Border to Visibility.Visible. This shows the box (border), message, and buttons.
You can even implement a semi-transparent rectangle underneath the border (over the rest of the form) that you set to visible at the same time. This will give you the nice "form dimmed" effect and also block the normal form controls from being clicked. A general note - for this to work, these controls need to be at the very bottom of your XAML as the z-index among controls at the same level is inferred from their placement in the XAML - lower in the code is top level on the form.
Let me know if you have any questions about implementing this if it sounds like what you are looking for.
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.
I am silverlight beginner and i am in a situation that i have to pop up a message box containing three buttons (Yes/No/Ok). Please do not give me the following suggestion(I already tried and tired) :
(1) Use Childwindow : Though it is a good solution but the way it pop ups is not like MessageBox pop up because in message box pop up we can see clearly
the data behind but we cannot edit/click/change it whereas in child window pop up it is less visible. (So if you know any way to make childwindow back ground
visible just like MessageBox then you are most welcome to tell me alternatives).
(2) Use PopUp control : Because it do not pop up exactly and can be distuinguished easily from MessageBox and the data behind is always editable when PopUp control is pop-Uped and if i set it to Collapsed then it show nothing. So i want pop up exactly like MessageBox.Show() Pop Ups.
Whereas in MeassageBox.Show() we can see that when it is pop uped the GUi behind is visible but not clickable and the way it Pop ups is perfect so i want
something that could Pop up exactly the same way with three buttons on it.
Could some one please help me in achieving my target ?
If I understand the question, you want a popup in the default MessageBox style, only with Yes/No/OK buttons. Recognize that there is not an ideal solution -- even the Windows API (which you don't have access to in Silverlight outside of full trust) doesn't provide this combination of buttons (without using advanced techniques anyway).
So, you are left with the non-ideal options of making use of Popup or ChildWindow. I think it would be misguided to try and mimic the exact style of the Windows dialog popup, since that style depends on the system, which you don't have access to from Silverlight. Instead, I recommend just choosing a style that you are comfortable with, and which matches the theme of your application.
In any case, as with all controls, you have two options for styling ChildWindow:
1) Modify its style properties like OverlayOpacity, BorderBrush, etc. Take a look at the default control template to see how those properties are used in the control's presentation.
2) If you need to do more customization than the default template allows, then you can always copy-and-modify the ControlTemplate. That allows you fine-grained control over everything about the popup's appearance, including its open/close animations. There's lots of info on the web about modifying control templates (eg, MSDN).
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.
In WPF I am looking for a "do not show again" checkbox on my messagebox popup.
Does anyone know where I can get such a control or maybe how to copy the style of the regular WPF messagebox so I can create my own?
Thanks
Take a look at the Dialog Boxes Overview. The overview covers Message Boxes, Common Dialog Boxes, and Custom Dialog Boxes. In your case you'll want to create a simple Custom Dialog Box that includes a message, a checkbox, and however many buttons you need.
Basically you need to define a new code-behind file that includes your TextBlock, CheckBox, and Buttons in a panel object, and you need to extend Window. In your code-behind file you implement any necessary logic to implement the user's choice, and you return this result to the object containing the custom dialog box.
Make sure to pay special attention to this line of code when creating your custom dialog box:
// Open the dialog box modally
messageBox.ShowDialog();
The call to ShowDialog() will ensure that the user must take action against your dialog box before moving on to other parts of your application.
I think , you may have to create by yourself and it is really easy in the WPF
You could just use a dialog box. An easy way to do it would be to keep a variable in the project settings that would be updated on the popup close() event. So then you would just have to verify the value in the project settings before showing the popup.