Using the following code btn2 looks different to btn1 and btn3 yet they are using exactly the same image.
Public Class MyToolBar
Inherits ToolBar
Public Sub New()
MyBase.New()
Dim bmp1 = New BitmapImage(ImageUri.DeleteItem)
Dim bmp2 = New BitmapImage(ImageUri.DeleteItem)
Dim bmp3 = New BitmapImage(ImageUri.DeleteItem)
Dim img1 = New Image With {.Source = bmp1}
Dim img2 = New Image With {.Source = bmp2}
Dim img3 = New Image With {.Source = bmp3}
Dim btn1 = New Button With {.Content = img1}
Dim btn2 = New MyButton With {.Content = img2}
Dim btn3 = New Button With {.Content = img3}
Me.AddChild(btn1)
Me.AddChild(btn2)
Me.AddChild(btn3)
End Sub
End Class
Public Class MyButton
Inherits Button
End Class
The only difference in the code is btn2 is constructed with MyButton. MyButton is a simple inheritance of Button, no other code.
btn1 & btn3 appear as expected; flat. btn2 appears semi raised and has a black border.
The order I add the buttons to the toolbar makes no difference. That is - the weird appearance of btn2 moves to the location that it is added to the toolbar.
I've dumped and compared the properties, to 2 levels, of btn1 and btn2 and there is only the expected differences except for:
btn1.DependencyObjectType.IsSecurityCritical=False btn2.DependencyObjectType.IsSecurityCritical=True
and
btn1.DependencyObjectType.IsSecurityTransparent=True btn2.DependencyObjectType.IsSecurityTransparent=False
Anything else I should look into?