I have a popup window like this,
<controls:ChildWindow Background="Aquamarine">
<RichTextBox>
<Paragraph x:Name="WarningMessage" >
<Run>Test 1234</Run>
</Paragraph>
</RichTextBox>
</controls:ChildWindow>
I've removed most of the xaml for clarity, but the problem is that I have set the child window to have a background of Aquamarine, but the rich text box control still has a white background.
Is there any way to make the rich text control use the colour of the parent control?
RichTextBox's template defines default background as white. To change it you have to set Background property of the RichTextBox to different color. In your case "Transparent" color will do the trick.
<RichTextBox Background="Transparent">
...
Related
This post is about the controls contained within a WPF Border control. It's also about having a border that can appear and disappear without affecting the contained controls.
For the record, I'm using C# and WPF and most of the view stuff is using XAML. I also use MVVM although I'm not sure that's going to be related.
What I had planned for was a border around a control that I could make appear and disappear, for the effect of a highlight or something like that. But when I change certain properties of the Border, for example the Opacity or Visiblity, they impact on the contained controls. I have also tried changing the Background property to Transparent and that has not made a difference.
I do know that some controls have a Border property, but that's not really the case for my situation.
How can I do this?
Thanks
Try this:
<Grid>
<Border BorderThickness="2">
<YourControl />
</Border>
<Border Opacity="0.5" BorderBrush="Red" BorderThickness="2" />
</Grid>
This way you can change the opacity of the second border without affecting your control. The trick is that Grid ensures that both elements inside it have the same dimensions.
Also notice how your control is wrapped in another border with the same thickness but with no brush. This is to keep the second border from obscuring your control.
I want a custom Control in WPF which have a appearance similar to HTML, we use for showing Images in the centre of the screen with the whole screen locked and only image is showing.
I dont want to show images, I want to show UserControls within this section.
Can someone give suggestions of this?
In your Window, put all your controls in a single Grid, with a Border control (that contains your image) as the last item in the Grid (which means it will display on top of the other items). Toggle its Visibility via binding or code. Adjust styles as required.
<Window>
<Grid>
<!-- window controls go here --->
<Border Visibility="..." Background="#80000000"> <!-- EDITED -->
<!-- overlaid image (and/or other controls) goes here --->
<Image
Source="..."
Width="..."
Height="..."
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<Grid>
</Window>
In Windows applications this is generally achieved using a modal dialog, i.e. you create a normal WPF window and show it using ShowDialog.
I have a Silverlight DataGrid and I can't figure out how to style it. When the user hovers over a row, the background color that is applied to the row (by default) does not fit well with the rest of the UI. I want to change this background color on hover. How do I do it?
You need to assign a DataGridRow Style to DataGrid.RowStyle that changes the animation for the VisualState for MouseOver. The Default styles for DataGrid can be found here.
In the style for DataGridRow you want to change this:
<Rectangle x:Name="BackgroundRectangle" Grid.RowSpan="2" Grid.ColumnSpan="2" Opacity="0" Fill="#FFBADDE9"/>
That Rectangle is opaque but is made visible on mouse over. Changing the fill will change the background color on mouse over.
I have a textblock in a grid in WPF.
I want the text to dynamically size (font) when resized. At the moment textboxes, comboboxes do this, but the the textblock stays the same. Is it possible?
Instead of trying to manually rig a TextBlock to do this, just edit the default template of a TextBox and remove the border and background, then in the style make it set the IsReadOnly flag. This way you get the textblock sizing, as well as copy-paste for free.
You can use a ViewBox for this.
eg:
<Viewbox Stretch="Uniform">
<TextBlock Text="Test" />
</Viewbox>
use expression blend for getting the default template of TextBox, then you can edit it as you required.
when hovering my mouse over a wrapped textbox, I want to get the word or text position immediately under the mouse.
I've seen some samples for a single textbox, like this one, but I have a wrapped textbox.
I think I might be able to do this if I had a MeasureString function but I don't have that either in Silverlight (would be useful for other things).
Example TextBox
<Textbox TextWrapping="Wrap" Width="50" Text=" ... " />
There isn't this ability in Silverlight today. Here's what I would do as a workaround:
Have an invisible (Opacity 0, IsHitTestVisible=False) WrapPanel with a TextBlock for each word.
Make the WrapPanel the same size as the TextBlock
Adjust margins on the TextBlocks and WrapPanels until you get similar spacing.
Do hit testing on the WrapPanel with the TextBlocks to determine the word