Here is the visual tree (the selected Rectangle is the drop shadow your refer to):
The following code hides the Rectangle:
class MyDocumentViewer : DocumentViewer
{
public void RemoveToolbarShadow()
{
var r = this.FindType<System.Windows.Controls.Border>()?
.FindType<Grid>()?
.FindType<DockPanel>()?
.FindType<System.Windows.Shapes.Rectangle>();
if (null != r) r.Visibility = Visibility.Hidden;
}
}
Helper extension:
static class DependencyObjectExtensions
{
internal static T FindType<T>(this DependencyObject reference) where T : DependencyObject
{
int n = VisualTreeHelper.GetChildrenCount(reference);
for (int i = 0; i < n; i++)
{
var c = VisualTreeHelper.GetChild(reference, i) as T;
if (null != c) return c;
}
return null;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.