Change color of zoom rectangle - wpf

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

Related

textbox wpf to right

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.

Style to add color to image in WPF

How can I create a Style with WPF that applies a color layer to ANY image on mouse over as described below. Image has a transparent background.
Example 1 (normal and mouseover):
Example 2 (normal and mouseover):
For example, let's say I have a RadioButton with an Image as its Content. I planned defining a ControlTemplate to do this but I'm stuck with how to apply a color "layer" to the image.
<RadioButton Template="{StaticResource ColorTemplate}">
<Image Source="/MyProject;component/someimage.png"/>
</RadioButton>
<ControlTemplate x:Key="ColorTemplate">
<Border Background="Transparent">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<--CAN THIS BE ACHIEVED THROUGH TRIGGERS?-->
</ControlTemplate.Triggers>
</ControlTemplate>
Is it possible to make this a generic style in XAML that could be applied to any image so that there would be no need to include two (or more) images of the same only to achieve these color effects.

how to add a border around canvas wp7

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>

WPF Border Thickness increase direction

Hey. Another WPF question. In my XAML code I have a border:
<Border x:Name="myBorder" Background="AliceBlue"
Width="200" Height="200"
BorderThickness="10" BorderBrush="Black">
</Border>
and somewhere in code I increase the BorderThickness
double thickness = myBorder.BorderThickness.Bottom + 2;
myBorder.BorderThickness = new Thickness(thickness);
and the result is that the border's weight increases but not outside the 200x200 width-height, but inner, decreasing the dimension. Is there a way to do the opposite?
Well, actually you should set the width and height on the inner or outer control of the border, not on the border itself. Then you can set a negative margin for the border, equal to minus the value of the border thickness. Something like this should to the trick:
<Border x:Name="myBorder" Background="AliceBlue"
Margin="-10,-10,-10,-10" BorderThickness="10" BorderBrush="Black">
<Button Background="Red" Content="Test" Width="200" Height="200"></Button>
</Border>
It looks like you need to increase Width and Height accordingly.

Outer and Inner Glow with transparent WPF Buttons

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>

Resources