0

我在代码中创建了几个ListBox-es,并且在后面的代码中设置了样式和触发器(我必须这样做,因为每个都是ListBox不同的,并且ListBox在 . .

IsMouseOver我这样做,除了向触发属性添加阴影效果外,一切正常。

DropShadowBitmapEffect myDropShadowEffect = new DropShadowBitmapEffect();
myShadowColor.ScA = 1; 
myShadowColor.ScB = 0;
myShadowColor.ScG = 0;
myShadowColor.ScR = 0;
myDropShadowEffect.Color = myShadowColor;
...

Trigger trigger = new Trigger();
trigger.Property = UIElement.IsMouseOverProperty;
trigger.Value = true;
trigger.Setters.Add(new Setter { Property = ListBoxItem.BitmapEffectProperty, Value = myDropShadowEffect });

for (int i = 0; i < myListBox; i++)
{
  var x = new Style();
  //Bunch of Style setters  
  x.Triggers.Add(trigger);

  myListBox[i].ItemContainerStyle = x;
}

你能帮我理解我在那里做错了什么吗?

4

1 回答 1

0

我编辑了这条线

trigger.Setters.Add(new Setter { Property = ListBoxItem.BitmapEffectProperty, Value = myDropShadowEffect });
于 2013-05-28T21:41:15.707 回答