Dani,
for the sake of backwards compatibility we cannot understand that these dependency properties were removed. Moreover:
1. We migrated from Silverlight RadControls 2010 Q3 SP1 and these dependency properties were not marked with the [Obsolete] attribute.
2. The design was not that awkward nor confusing that it was advisable to delete them. In the code posted below there are some comments that it doesn't work in XBAP scenarios, but you can always throw an exception in that case ("offset properties not supported in XBAP deployments")
I've spend a fair amount of time figuring out how to perform these calculations. At least you could have updated the documentation so upgrading to a newer version is less painful. An example is "
http://www.telerik.com/help/silverlight/radrichtextbox-features-radrichtextboxribbonui.html" (In the versions before 2011.Q3.Beta (2011.3.1020), it was based on
RadRibbonBar, but starting from the version in question, it uses the new
RadRibbonView instead. The advantages of using the new control compared to the old one are described in detail in
this blog post.)
The previous version of Telerik contained the following code for the calculations:
using System;
using System.Windows;
namespace Telerik.Windows.Controls.RadWindowPopup
{
internal abstract class BrowserWindowPopup : WindowPopup
{
public override Size GetRootSize()
{
return ApplicationHelper.ApplicationSize;
}
protected override void OnOpened(EventArgs args)
{
base.OnOpened(args);
if (this.WindowStartupLocation == WindowStartupLocation.CenterOwner ||
this.WindowStartupLocation == WindowStartupLocation.CenterScreen)
{
this.PositionWindow();
}
}
protected override void OpenPopup()
{
var owner = this.Owner as RadWindow;
if (owner != null && !owner.IsOpen)
{
throw new InvalidOperationException("Cannot set Owner property to a RadWindow that has not been shown previously.");
}
}
// XXX This won't work for XBAP if in a different window than the main one.
private void PositionWindow()
{
// TODO: Decouple this method from RadWindow class.
var window = this.Child as RadWindow;
if (window == null)
{
return;
}
var rootSize = this.GetRootSize();
if (rootSize.Width <= 0 || rootSize.Height <= 0)
{
var rootVisual = ApplicationHelper.GetRootVisual(this.Owner);
rootVisual.LayoutUpdated += this.OnApplicationLayoutUpdated;
return;
}
if (window.ActualWidth <= 0 || window.ActualHeight <= 0)
{
window.LayoutUpdated += this.OnWindowLayoutUpdated;
return;
}
if (this.WindowStartupLocation == WindowStartupLocation.CenterOwner &&
this.Owner != null &&
(this.Owner.ActualWidth <= 0 || this.Owner.ActualHeight <= 0))
{
this.Owner.LayoutUpdated += this.OnWindowOwnerLayoutUpdated;
return;
}
Point parentStart = new Point(window.LeftOffset, window.TopOffset);
Size parentSize = this.GetRootSize();
if (this.WindowStartupLocation == WindowStartupLocation.CenterOwner &&
this.Owner != null)
{
parentStart = this.Owner
.TransformToVisual(ApplicationHelper.GetRootVisual(this.Owner))
.Transform(parentStart);
parentSize = new Size(this.Owner.ActualWidth, this.Owner.ActualHeight);
}
Rect parentRect = new Rect(parentStart, parentSize);
PlacementHelper helper = new PlacementHelper(parentRect,
new Size(window.ActualWidth, window.ActualHeight),
0,
0,
this.GetRootSize(), window.FlowDirection);
Point newLocation = helper.GetPlacementOrigin(PlacementMode.Center);
window.Left = newLocation.X;
window.Top = newLocation.Y;
window.UpdateLayout();
}
private void OnApplicationLayoutUpdated(object sender, EventArgs e)
{
var rootVisual = ApplicationHelper.GetRootVisual(this.Owner);
if (rootVisual.ActualWidth > 0 && rootVisual.ActualHeight > 0)
{
rootVisual.LayoutUpdated -= this.OnApplicationLayoutUpdated;
this.PositionWindow();
}
}
private void OnWindowLayoutUpdated(object sender, EventArgs e)
{
var window = this.Child as RadWindow;
if (window != null)
{
if (window.ActualWidth > 0 && window.ActualHeight > 0)
{
window.LayoutUpdated -= this.OnWindowLayoutUpdated;
this.PositionWindow();
}
}
}
private void OnWindowOwnerLayoutUpdated(object sender, EventArgs e)
{
if (this.Owner.ActualWidth > 0 && this.Owner.ActualHeight > 0)
{
this.Owner.LayoutUpdated -= this.OnWindowOwnerLayoutUpdated;
this.PositionWindow();
}
}
}
}
Note: one also needs the code for the ApplicationHelper class.