When I change the style of my window to WindowStyle="None" and AllowsTransparency="True" I lose the inactive window visuals. Is there a trigger I can use in the XAML style that can show a hidden mask or opacity changes in the main window when another window has focus? I'd like to be able to achieve this within the XAML and not programatically.
You can change an opacity mask of window by changing OpacityMask property with trigger when Window.IsActive is true. OpacityMask is a brush so you can provide anything you want, including gradient or something more complex. If I remember correctly framework will take only alpha channel from this brush.
Related
I'm trying to create a simple 'dialog'-type window in WPF. However, for this specific instance, I do not want the client area to have a border, or even a background for that matter. I just want my controls to appear over the background of the window the way they do with a simple MessageBox.
I played with the different values for WindowStyle but they all called out the client area with a color. I also tried simply setting the client's Background to transparent, but that didn't work either just rendering it in black.
Here's a crappy Photoshop job showing what I'm after:
Note: I'm not after the messagebox contents themselves--e.g. the icon, buttons and message, etc.--I'm only asking about how to suppress the client area from appearing in any window. I just happened to use a messagebox as an example as someone linked to it in their answer.
As you can see (or rather can't) there is no visible demarcation of the client area.
Used to be so simple in WinForms, but WPF has me stumped. Anyone?
I'm not sure what you're after. Do you want only the controls on your dialog to be visible with the dialog's border and background transparent? If so, try these settings on your dialog:
WindowStyle="None"
ShowInTaskbar="False"
AllowsTransparency="True"
Background="Transparent"
If you want your dialog's background color to the Winform System.Control with no border, set your form's Background like this (instead of Transparent):
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
I have a UserControl that have a storyboard that moves a control (within my UserControl) out of the usercontrol (using a TranslateX RenderTransform).
When I move the object out of the control it shows on the parent Page (that hosts my UserControl). Is there a way to just hide it when it reaches the boundaries of my UserControl?
At the end of your storyboard set the animated controls visibility to collapsed/opacity = 0. If that animation is too abrupt for you, animate the opacity to 0 as the storyboard progresses. To detect when the animation goes out of your control would be rather difficult. You're probably best off "guessing" by waiting a few tenths of a second.
You could try setting the Canvas.ZIndex so that the Control is behind the Parent Control
The Z-Index doesn't work since its outside my UserControl.
I was thinking more like using the "Clip" property, but I'm not really familiar with it :/
What I finally did :
Use a Canvas (instead of a Grid) as my LayoutRoot of my UserControl
Added a Canvas.Clip that matches the size of my UserControl
On the SizeChanged of my UserControl I resize my Clip to fit the new size.
I'd like to post the XAML here but somehow the CodeSample does not work :/ Sorry
Are there any default exceptions where wpf controls are not focusable?
My controls need to be all focusable, but I do not want to set everytime I create a control
make focusable="true"
In general, WPF controls work as expected with regards to being focusable or not. Things you can interact with such as button, list/items controls, textbox are all focusable. Non-interactive controls like TextBlock, Image are non-focusable. So normally, you don't have to deal with setting the value of the Focusable property. I'm not sure if this is what you're looking for but I hope this helps.
I would like to make a small WPF app window semi-transparent and on top of other windows.
When I change settings on the top level Window it only seems to effect the contents, not the titlebar or border.
Is this possible with WPF??
Thanks
WindowStyle and AllowsTransparency are the two properties you'll have to change.
In order to have your window sit on top of all the other windows, you're going to want to set Window.Topmost to True as well. To move the window, handle one of the Mouse events on the border you added then call Window.DragMove in the event handler.
I'm not sure this is the best answer, but:
AllowsTransparency="True" WindowStyle="None"
gets rid of the title and border -- now Opacity effects everything else. I then added my own border and Close button. Now I just need some Move functionality.
AllowsTransparency seems to do the trick, but it forces WindowStyle to None.
Is it possible in WPF to embed a ProgressBar in the Background of a TextBox?
Yes, but there are varying levels of integration you could achieve.
The simplest way would be to host a ProgressBar and TextBox with see-through background in the same Grid:
<Grid>
<ProgressBar/>
<TextBox Background="#00ffffff"/>
</Grid>
Importantly, the background color is transparent but visible to hit testing. #00000000 would not work as expected because clicking on the TextBox would actually be clicking on the ProgressBar.
You could also retemplate the TextBox to incorporate the ProgressBar more intrinsically into its template. However, this would be of limited use unless you wrote your own control while you're at it.