private Thickness calculateThickness(ElementPresenter host) { var element = host.Element; if (element == null) { return(new Thickness()); } double baseThickness = host.ElementBorderWidth; switch (element.Index) { case 0: case 1: case 3: case 4: return(new Thickness(0, 0, baseThickness, baseThickness)); case 2: case 5: return(new Thickness(0, 0, 0, baseThickness)); case 6: case 7: return(new Thickness(0, 0, baseThickness, 0)); default: return(new Thickness(0)); } }
public BorderThicknessUpdator(ElementPresenter host) { if (host == null) { throw new ArgumentNullException("host"); } this.host = host; DependencyPropertyDescriptor.FromProperty( ElementPresenter.ElementBorderWidthProperty, typeof(ElementPresenter)) .AddValueChanged(host, UpdateNeeded); DependencyPropertyDescriptor.FromProperty( ElementPresenter.ElementProperty, typeof(ElementPresenter)) .AddValueChanged(host, UpdateNeeded); }
private void updateElementBorderThickness(ElementPresenter host) { host.SetElementBorderThickness(calculateThickness(host)); }