WPF: TextBox with ProgressBar - wpf

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.

Related

WPF: How to change button content (text) with a double click at runtime

I have a button in WPF, I want to change the text when I double click on it, that is I want the cursor to appear and type the text that is to be shown as the content (similar behavior as when pressing F2 on a desktop shortcut).
I guess I could detect a double click and then show a textbox with a transparent background, that will get me the cursor, type the text in this new textbox, set it to the buttons content and delete the textbox, but that doesn't seem the right way to do it.
I guess what I had in mind, is that I am developing a diagramming tool using shapes. Since shape doesn't derive from ContentControl I cannot put a text box inside it, and I want to simulate this behavior. I was thinking of making a custom control but that might be too much work for this, and am not quite familiar with this topic yet. I guess another approach would be to use an adorner (maybe a border) and since it derives from contentcontrol I can do the same thing as joe suggested. any ideas?
Another thing I could do would be to put the shape in a grid, and then put the textbox on top of the shape, but I am not sure how would that be as a design principle, and also I don't know if the hit testing would only be on the shape or the grid.
Since this is WPF, you can put a TextBox inside your Button with no trouble. If you don't want the textbox to have a border and white background -- i.e., if you want it to look like you're just typing directly into the button -- then you could remove them by setting BorderWidth to 0 and Background to Transparent.
What you probably want to do is have your Button's Content be a Grid that contains both the normal content (probably a TextBlock) and the TextBox, with the TextBox initially hidden (Visibility = Collapsed). Then when you get the double-click event, you would hide the TextBlock and show the TextBox.
<Button>
<Grid>
<TextBlock Name="buttonText">Double-click to rename me</TextBlock>
<TextBox Name="buttonEdit" Visibility="Collapsed" MinWidth="100"/>
</Grid>
</Button>

In WPF, how do I create a dialog-like window (i.e. gray background with no border around the client area)?

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}}"

Are all WPF controls FOCUSable?

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.

Turn off Tooltip of WPF Toolkit chart control

I am using the WPF ToolKit ChartControl to create a columneries chart. Whenever I move mouse to my Chart, the ToolTip value will be displayed. I dont need this ToolTip, So how can I turn this off?
I haven't used this control so I can't say for sure but in general you can disable tooltips by setting the attached property ToolTipService.IsEnabled to false like this:
<TextBlock ToolTip="World" ToolTipService.IsEnabled="False">Hello</TextBlock>

How to change the look of an inactive window in XAML?

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.

Resources