I have a window with some contents. I'd like to click a button and another control (a grid/border) slides up. But i'd like the contents of the window that is under this slided up control to be modal. I cannot click or use keyboard to activate anything.
Thank you.
For a modal window I would use the ChildWindow class. Microsoft provides the templates used for all of their major controls and objects so one can take what they did and change it. The ChildWindow template and styles page has a pretty good explanation of the layout so one can figure out what to change. You should just be able to instantiate a new ChildWindow, set its template to your custom template, and rock out!
Sounds to me you could do with using the ChildWindow control instead, which handles most of this for you. Make a copy of its template and tweak it up to get your slide-in effect.
You can create a control filling the complete canvas and make it transparent.
Related
Hi I have a WPF application with various UserControls that contain key functionality. I want to be able to show say a FileManager UserControl in a tab on the main application, or have a dialog pop up when required, that contains the same UserControl.
It seemed like a good idea to create a modal Window and set its Content to the FileManager Usercontrol. But when I am finished with it, I am not sure how to close the containing Window, using a button on the UserControl. Is there an elegant way of doing this without having to store a reference to the Window in the UserControl?
Thanks for any advice!
Create an Event which is called when the respective button on the user control is clicked. That way, the containing control can react to the event in the appropriate manner. For example, a dialog could just close itself.
Is closing a window something that is integral to the functionality of the control in all the contexts where the control is hosted? E.g Does closing a window apply to the case where the control is hosted in a tab of the main app?
If not then you might be better off separating window closing code out of the UserControl in into the window/dialog that is hosting it - using events or whatever to tie the two together.
A while I go, I made a demo application with Expression Blend.
My first screen is a big selections of Buttons, so when user click on any of button, it goes to the MainView.
Then in the MainView, I have a list of Menu items that user can click and shows up its corresponing DisplayView. (Appointment Menu Item will shows up AppointmentView etc).
Everything is good, I can click the MenuItem, the Views shows up with animation and transition effects.
But the thing is, with creating in Expression Blend, the MainView, Menu, AppointmentView etc every thing is predefined in the XAML. So when user load the first screen has to load everything into memory.
Now thinking of it, shouldn't the MainView etc be dynamically add into the screen?
How do I do it with Expression Blend? Or the only way to do is just....do it in code-behind myself (writting StoryBoard etc for the dynamic add/remove controls?)
If there is any example/tutorial of doing it, it will be great.
I guess you have very limited possibilities to conditionally load or unload controls exclusively in Blend without writing code-behind.
In general an opening tag in XAML is equivalent to a parameter-less constructor of some class object. As soon as you write the tags your are instantiating an object but that doesn't mean that it's visual appearance is loaded into memory. This only happens when the control is actually shown on the screen.
In my opinion the leanest way to control the appearance of some control is to use a single-child control. Take a Border control for example and add the user control you want to conditionally load to its child property, so you can decide for example whether to load or unload a control.
But unfortunately I think you have to do this in code as well. Take this easy code snippet:
// either instantiate in code or use from markuup
Border myBorder = new Border();
// the control you want to conditionally appear and disappear
UserControl myUserControl = new UserControl();
myBorder.Child.Add(myUserControl);
Of course a much more sophisticated approach is to use Grids. Here you have to use attached properties to add or remove child elements:
// either instantiate in code or use from markuup
Grid myGrid = new Grid();
// the control you want to conditionally appear and disappear
UserControl myUserControl = new UserControl();
// set the target position inside the Grid via the Grids attached properties
Grid.setRow(myUserControl, 1);
Grid.setColumn(myUserControl, 0);
// actually add the control
Grid.Children.Add(myUserControl);
Although I am pretty sure you were aware of all of that I am hoping it helped a bit :)
This is a sort of extension of this question I asked yesterday (the question gave me a contentcontrol that can overlay the current control). I now have a contentcontrol that can be overlayed on the current control via bindings (a modal type window). This works well and I am happy with this. One great feature would be if I could get the overlay to go over its parent.
currently the overlay will go into "My Control" control. What I would like is if I can still define it in that control (as that is were it is needed), but when it is displayed it can cover the whole main content area and / or the main window.
is this even possible?
Thanks
Sure it's possible, just wrap it into a Popup! :) You might have to manually stretch it though, but Popup is the control which will let you go outside the bounds of the parent view.
Another way is to host the MainContent in a grid and add a collapsed content control after the MainContent.
To show the popup: put it in the collapsed content control and make it visible.
To hide the popup: collapse the contentn control and remove the popup.
I am new to both Silverlight and Blend 4.
I am trying to make a Image Gallery, where u click on the image and it shows details of the same.
I used VisualStateManager to get a mouseOver and mouseOut effect to the thumbnails. and here is wat i want. I want to add the VisualState's to all my thumbnails through Style. (I had seen this in some forum, but i cudnt figure it out how he did it.)
Here is wat i want:
I have set of thumbnails to, which need to scale up on MouseOver and come back to normal on MouseOUT. I created a VisualStateManager States.
But i want to use the state as a
common state for all the thumbnails
and apply it to the thumbnails through
Style.
Is this possible? If so how?
If not? then is how can i achieve it.
Would be really thankful to any one who can help me :) just that this is a bit urgent. :(
MSDN documentation says that you should be able to add the VisualStageManager XAML tag to any control which inherits from UIElement and accepts child controls.
It seems to me then that the best way to do this is to create a UserControl for your thumbnail and set the VisualStateManager there. You can then reuse that UserControl.
More reading material:
MSDN UserControl documentation
Adding behaviour to stock controls
From what I understand, the popup exists within it's own visual tree. However, I've noticed a few properties, Clip and ClipToBounds. What I am wanting to do is Visually clip a popup at the right and bottom edges of a window regardless of the fact that the popup is independent of the bounds of the window. I'm not using XAML, but if somebody knows how to do it in XAML, then that's fine. I can get to the main window using System.Windows.Application.Current.MainWindow. Is it possible from this to get a value that I can use to clip the popup? I'm assuming that if there is a value that I can use, then I would be able to bind the clipping of the popup to that value. This is really not necessary since after the popup initially opens, if the window gets moved or resized, the popup closes. So I would really only need to clip the popup when it opens. The reason I would like to do this is because although I am using a popup, I don't want it to appear as a popup that exists outside of the window. FYI this is for a popup calendar for a custom datebox. Any ideas, as well as clarification of misconceptions that I may have, would be greatly appreciated.
Furthermore, the popup can be launched from a user control that is not directly on the Main Window. So in that case it would be easier to use a popup. As apposed to a UC inside the XAML
I know this is a year old post, but in case any others come here looking for answers... If you don't need the popup to be outside of your window, why use a popup at all? It'd be far easier to simply use a control in a canvas (for instance) and control it via its Visibility property. Then you'd automagically get your clipping.