Reputation:
I am able to put a halo around an UI element like a textbox.
The problem is that it nearly is invisible.
I do it with
Effect glowEffect = new DropShadowEffect
{
BlurRadius = 20,
Color = Colors.Gold,
ShadowDepth = 10,
Opacity = 1,
RenderingBias = RenderingBias.Quality
};
and apply it with
tbxSearch.GotFocus += (sendGF, argGF) => { (sendGF as TextBox).Effect = glowEffect; };
tbxSearch.LostFocus += (sendLF, argLF) => { (sendLF as TextBox).Effect = null; };
I tried changing all the parameters but nearly nothing changed. Thanks
Upvotes: 0
Views: 100
Reputation: 2583
I have not found a better solution than:
That can also be done in a rountine.
public void Add(TextBox tbx, int num)
{
var glowEffectRed = new DropShadowEffect
{
BlurRadius = 50,
Color = new Color { A = 255, R = 255, G = 0, B = 0 },
ShadowDepth = 0,
Opacity = 1,
RenderingBias = RenderingBias.Performance
};
tbx.Effect = glowEffectRed;
var grd = (Grid)tbx.Parent;
grd.Children.Remove(tbx);
for (int iii = 0; iii < num; iii++)
{
var tbxAdd = new TextBox();
tbxAdd.Effect = glowEffectRed;
Grid.SetRow(tbxAdd, Grid.GetRow(tbx));
tbxAdd.Height = tbx.ActualHeight;
tbxAdd.Width = tbx.ActualWidth;
grd.Children.Add(tbxAdd);
}
grd.Children.Add(tbx);
}
and then called with the number of times the effect has to be re-applied
Add(tbx1, 1);
Add(tbx2, 5);
Add(tbx3, 10);
Add(tbx4, 15);
If used statically this might work. If the effect has to be dinamic this can surely lead to performance problems.
Upvotes: 0