private void UpdateMargin() { if (Target == null) { return; } if (!IsVisible) { return; } ScrollViewer sc = Target.Template.FindName("PART_ContentHost", Target) as ScrollViewer; if (sc == null) { return; } ScrollBar sbV = sc.Template.FindName("PART_VerticalScrollBar", sc) as ScrollBar; ScrollBar sbH = sc.Template.FindName("PART_HorizontalScrollBar", sc) as ScrollBar; double w = (sbV != null) && sbV.IsVisible ? sbV.ActualWidth : 0; double h = (sbH != null) && sbH.IsVisible ? sbH.ActualHeight : 0; Thickness m = new Thickness( Target.Margin.Left + Target.BorderThickness.Left, Target.Margin.Top + Target.BorderThickness.Top, Target.Margin.Right + Target.BorderThickness.Right + w, Target.Margin.Bottom + Target.BorderThickness.Bottom + h); if (!Margin.Equals(m)) { Margin = m; } }
public bool AreEqual(Guid firstMarginId, Guid secondMarginId) { if (!marginDataAccess.Exists(firstMarginId)) { throw new ArgumentException("The first margin argument not exist in database." , "firstMarginId"); } if (!marginDataAccess.Exists(secondMarginId)) { throw new ArgumentException("The second margin argument not exist in database." , "secondMarginId"); } Margin firstMargin = marginDataAccess.Get(firstMarginId); Margin secondMargin = marginDataAccess.Get(secondMarginId); return(firstMargin.Equals(secondMargin)); }