Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CommandRouting using a button.
Message
From
15/04/2008 16:34:06
 
 
To
15/04/2008 14:38:20
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01309791
Message ID:
01310909
Views:
13
>These are kind of best of what I've figured out answers. i.e. I'm guessing.
>
>>It's becoming clearer. But I'm afraid I still don't 'get' what bit of the Commanding infrastructure actually sets the CommandTarget value if it is not specifically defined. I also don't see 'when' it gets set.
>
>I think it's maybe in the RoutedCommand Class but I couldn't find anything explicit on this. It appears to attach itself to the windows GotFocus Event in order to find the target.

I guess I can't see what else can be responsible.....

>
>>I'm also wondering what happens when a window has multiple focus scopes holding potential command targets? Presumably the window element with the logical focus will be the element with logical focus in the most recently accessed focus scope? (Must be a clearer way of expressing this but it eludes me :={)
>
>No the focus scope for a routed command appears to stay fixed on the window and uses it's logical focus as the target.
>
>When you set a focus scope. It totally excludes itself and it's children from the parents focus scope. So a command target in a FocusScope under the window will not execute unless it is explicitly targeted.
>
>For instance, I have a textbox on my toolbar. The toolbar creates a FocusScope I also have a paste button on my toolbar.
>
>When I enter a textbox in my main window and I have something I can paste in the buffer, the paste toolbar button activates. If I move focus off to an item that will not accept a paste it deactivates.
>
>When I enter the textbox on my toolbar the paste button does not highlight. If it is already highlighted because I had focus on a pasteable target in my main window it stays highlighted. But pressing it pastes to the main window textbox not to the toolbar textbox.

The scenario I was thinking of was something like
<Window>
<StackPanel FocusManager.IsFocusScope="true">
<Button Command="ApplicationCommands.Save" />
</StackPanel>
<StackPanel FocusManager.IsFocusScope="true">
<TextBox x:Name="T1"/>
</StackPanel>
<StackPanel FocusManager.IsFocusScope="true">
<TextBox x:Name="T2" />
</StackPanel>
</Window>
and which textbox becomes the CommandTarget.

>HTH
>
>>On an unrelated note I just stumbled across the UIElement.SnapToDevicePixels property that I was not aware off and that would have answered Rick's criticism that it was not possible to disable anti-aliasing :=}
>
>I saw that too but haven't played with it yet. I know when it is off like it is for a few moments during scaling operations it looks pretty rough.

Must try it. IAC it gives you the option of how to display an item and AFAICS the only third option is to restrict available sizes to pixel boundaries so that no correction is necessary....
Best,
Viv
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform