I want my WPF Button to get an outer glow effect when the mouse hovers over it. How can I achieve this when the Button is transparent?
When I use a BitmapEffect such as a DropShadow or OuterGlow the glow appears at the inside of the Button as well because it is transparent. But I want the glow to be only at the outside.
Have you tried adding the outer glow to a border?
<Border Width="100" Height="100" Background="Transparent" BorderBrush="White" BorderThickness="1">
<Border.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="Red" GlowSize="3" Opacity="1" />
</Border.BitmapEffect>
</Border>
Related
I'm using OxyPlot in my application. I want to change the color of the rectangle when marking an area for zooming.
I just used Controller to bind the left mouse button to zoom:
ChartController = new PlotController();
ChartController.BindMouseDown(OxyMouseButton.Left,PlotCommands.ZoomRectangle);
To Color the Zoom Rectangle in Oxyplot, you can customize the ZoomRectangleTemplate.
For Example,
<oxy:PlotView Model="{Binding MyModel}" Controller="{Binding ChartController,UpdateSourceTrigger=PropertyChanged}">
<oxy:PlotView.ZoomRectangleTemplate>
<ControlTemplate>
<Border BorderBrush="Black" BorderThickness="1">
<Rectangle Fill="Orange" />
</Border>
</ControlTemplate>
</oxy:PlotView.ZoomRectangleTemplate>
</oxy:PlotView>
This would provide you the desired output
I have canvas with user control (border with textbox). when I put sth I want to resize textbox with border from left to right side. I have event textBox_TextChanged, and there I set new border width from textbox width.
please look at image
Do you want the border+textbox to expand to the left as you type? Try to set the Canvas.Right to position your Border:
<Canvas Width="300" Height="200">
<Border Canvas.Top="10"
Canvas.Right="50"
BorderBrush="Orange"
BorderThickness="2">
<TextBox Text="{Binding Title}" />
</Border>
</Canvas>
Obviously, Title above is the viewmodel's property.
How to add border around canvas element? Border should be same size as canvas.
I am using below code for this, but couldn't able to achieve the result.
<Canvas Background="Transparent" Margin="69,-30,56,315" x:Name="LetterCanvas" >
<Border x:Name="CanvasBorder" BorderThickness="5" Height="271" Width="325">
</Border></Canvas>
You need to place the Border outside of the Canvas:
<Border>
<Canvas>
</Canvas>
</Border>
I have a Grid layout. In one row, I have a Border and inside it a ToggleButton(with negative left margin so that it appears half outside the border). I've added DropShadowEffect to the border. Something seems to be clipping the shadow effect and the togglebutton outside the border. Please refer to the code and the image below.
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition Height="140*" />
<RowDefinition Height="500"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="LightGray">
<Border Background="{StaticResource BorderFill}" Height="150" Width="400" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="20,0,20,10" BorderBrush="#FF999999" BorderThickness="1">
<Border.Effect>
<DropShadowEffect Color="Gray" BlurRadius="40" ShadowDepth="0.1"/>
</Border.Effect>
<ToggleButton Click="MenuToggleButtonClick" Margin="-6.5,0,0,5" Style="{StaticResource ExpandCollapseButtons}" Width="Auto" Height="Auto" x:Name="MenuToggleButton" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
</Border>
</Grid>
The left red arrow shows where the button is getting clipped and the right red arrow shows where the dropshadow is getting clipped. What is going on? How can I fix this?
It appears that this clipping only occurs when there isn't enough space for the inner Grid plus its margin. I was able to reproduce the behaviour in your screenshot if I resized the browser window small enough.
In your case, it appears there isn't enough height. A similar effect happens if there isn't enough width.
I'm not sure why this border clipping is happening. However, I found that if
I added the attributes MinWidth="440" and MinHeight="160" (the width and height of the inner grid plus its margin) to the outer Grid, I could no longer reproduce the clipping no matter how small I resized the browser window in any direction.
i am trying to get rid of button border and only display text, however a thin line around the text gets displayed even though i set borderThickness to 0 and borderbrush to transparent.
my xaml code for save button:
<Button Content="save" Name="btnSaveEditedText"
Background="Transparent"
Foreground="White"
FontFamily="Tw Cen MT Condensed"
FontSize="30"
Margin="-280,0,0,10"
Width="60"
BorderBrush="Transparent"
BorderThickness="0"/>
Is there anyway i can get rid of the button border?
You need to override the ControlTemplate of the Button:
<Button Content="save" Name="btnSaveEditedText"
Background="Transparent"
Foreground="White"
FontFamily="Tw Cen MT Condensed"
FontSize="30"
Margin="-280,0,0,10"
Width="60"
BorderBrush="Transparent"
BorderThickness="0">
<Button.Template>
<ControlTemplate TargetType="Button">
<ContentPresenter Content="{TemplateBinding Content}"/>
</ControlTemplate>
</Button.Template>
</Button>
The method that I recently found to be most useful for this was to have your button use the style of a toolbars. This will only use the image or text while only showing button borders on mouse over.
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
Content="save"
Name="btnSaveEditedText"
Background="Transparent"
Foreground="White"
FontFamily="Tw Cen MT Condensed"
FontSize="30"
Margin="-280,0,0,10"
Width="60"
BorderBrush="Transparent"
BorderThickness="0" />
You need to create a new Template for your buttons.
The easiest way to do this is open your project in Expression Blend, select the button and then right click and select "Edit Template > Edit a Copy..". This copies the existing template into one you can modify. It's easier if you create it in a resource dictionary.
Then select the template and on the Resource tab (on the right of the UI) select the ButtonFocusVisual. Select the Properties tab and expand the Miscellaneous section. This has BorderStyle and BorderThickness fields (among others). Set the style to None.
Templates will not solve this problem, your only course of action is to modify the WPF control. The solution is here:
How to remove ButtonChrome border (when defining the template of a border)?