I have one application in WPF.
In which we have some button control. On the click of the button it opnes a popup control.
The problems is after clicking on button it does not move focus on opened pop up.
I want the solution using XAMLcode only.there is no CS file.
Thanks
Harshil
To do this in XAML only you will need classes which let you invoke methods since that is necessary to move the focus around, Interactivity from the Blend SDK lets you do this to some degree but i did not get it to work with the Focus method. Possibly something like this markup programming library would work; you could also implement some custom markup extension which does the invocation, but in general XAML-only is not trivial here.
...and it is somewhat pointless to do that in the first place. If you have imperative code like "open popup then focus it" then just use code behind, that's what it is for.
Related
I'm making a custom dropdown button (since the one included in wpf requires too much hacking to style right). Now that i got the button bit out of the way i need to add the drop down part.
My first thought was to add a stackpanel and use that to contain the items but it gets cut off if it leaves the borders of the grid that the button is in. Next up was the popup primitive, it gets on top of everything nicely enough but position wise it just free floats and i haven't figured out how to make it follow the button it was spawned by. I also tried using contextmenu but that seems to have no positioning controls at all and just sits where the mouse made it..
Anyways wpf is a big package and I'm just getting into it, anybody know which direction i might find what I'm looking for?
Preferred approach normally is to use a Popup. You got two very important properties with a Popup
PlacementTarget and Placement
Setup a binding for PlacementTarget on the Popup to your custom Button and then use Placement to position the Popup accordingly w.r.t to the PlacementTarget(Button)
Placement accepts an enum of type PlacementMode which gives you quite a few options to position the Popup.
I have created an app which uses the storyboard feature in Xcode.
I need to put a button on a few views which is a "Call us" button. The button will have the same look, text and action associated with it.
It's that reason which I thought would be best to create a subclass of the button and set all the button properties from there.
There are no coding problems, but when I drag on a button to a view on the storyboard, change it's class to the "CallButton" subclass name - it simply ignores all the formatting.
Am I missing something? Is there an easier way to reuse a button? Normally (old school way) I would simply call the button from the code, but as I've used the storyboard, I need to drag and drop the button really.
Thanks for any advice!
Xcode wont reflect the changes you make programatically in your subclass, but if you're setting up the buttons look in your subclass it should look as expected when you run the application.
Ideally you would setup your CustomButton in its initWithFrame and initWithCoder methods.
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html
I have some simple code for popping up a "dialog"-like thing over part of my application window. The idea is, the user must dismiss the dialog before continuing to work with that part of the page.
This works by hovering a large semi-transparent rectangle over the part of the page that is supposed to be disabled - which does a nice enough job of blocking clicks to the region. You see this sort of thing a lot in WPF and Web apps, I think.
The problem I have is, the user can still reach all those juicy blocked controls by tabbing to them using the keyboard. "No problem", I hear you say, "just set the IsEnabled on the panel to false, thereby blocking keyboard access".
Unfortunately, disabling the controls:
Doesn't look very nice
Tends to have unintended consequences with custom styles and bindings further down the tree
So, is there a better way to disable a part of the page, without setting the "IsEnabled" property, such that it doesn't change the visual appearance of any of the controls?
Thanks,
Mark
Can you put your "dialog" XAML in a popup window? Then, call ShowDialog() on the window to make it a modal window? If you don't want your popup to look like a standard window, you could always syle it to remove borders, etc.
I solved this by subscribing to the PreviewGotKeyboardFocus event, from the parent element in the tree, and then handling the event such that focus never gets passed to the children.
Also, I had to explicitly remove focus from the "disabled" controls as well, of course.
i am trying to create a wpf app and have different parts in user controls.
in the navigation i have some buttons (now using the ribbon ctp). is it possible to change the main user control when different buttons are pressed in xaml. or is this just a bad way to do things?
sorry, really new to xaml and im trying to get my head arround it.
Further to what Carlo has said,
The way we do it is to have a blank grid in the place you want your controls to all appear and then use BlankGrid.Children.Clear() and BlankGrid.Children.Add() to set up which control is visible in this position.
We found that was the nicest programatically as we have a large number of custom controls, but Carlo's method would work nicely if you wanted to use the designer.
I think this is a pretty regular procedure in WPF. In my experience, me and other programmers put the controls where we want to show them and make their visibility hidden, collapsed or visible depending on what we want to show the user.
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.