mirror of https://github.com/AMT-Cheif/Stylet.git
WindowManager does not set Title binding if Title has a value already
This commit is contained in:
parent
64e83c526b
commit
68a826e66f
|
@ -130,7 +130,7 @@ namespace Stylet
|
|||
}
|
||||
|
||||
var haveDisplayName = viewModel as IHaveDisplayName;
|
||||
if (haveDisplayName != null && BindingOperations.GetBindingBase(window, Window.TitleProperty) == null)
|
||||
if (haveDisplayName != null && String.IsNullOrEmpty(window.Title) && BindingOperations.GetBindingBase(window, Window.TitleProperty) == null)
|
||||
{
|
||||
var binding = new Binding("DisplayName") { Mode = BindingMode.TwoWay };
|
||||
window.SetBinding(Window.TitleProperty, binding);
|
||||
|
|
|
@ -101,10 +101,41 @@ namespace StyletUnitTests
|
|||
this.windowManager.CreateWindow(model, false);
|
||||
|
||||
var e = window.GetBindingExpression(Window.TitleProperty);
|
||||
Assert.NotNull(e);
|
||||
Assert.AreEqual(BindingMode.TwoWay, e.ParentBinding.Mode);
|
||||
Assert.AreEqual("DisplayName", e.ParentBinding.Path.Path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateWindowDoesNotSetUpTitleBindingIfTitleHasAValueAlready()
|
||||
{
|
||||
var model = new Screen();
|
||||
var window = new Window();
|
||||
window.Title = "Foo";
|
||||
this.viewManager.Setup(x => x.CreateAndBindViewForModel(model)).Returns(window);
|
||||
|
||||
this.windowManager.CreateWindow(model, false);
|
||||
|
||||
var e = window.GetBindingExpression(Window.TitleProperty);
|
||||
Assert.IsNull(e);
|
||||
Assert.AreEqual("Foo", window.Title);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateWindowDoesNotSetUpTitleBindingIfTitleHasABindingAlready()
|
||||
{
|
||||
var model = new Screen();
|
||||
var window = new Window();
|
||||
var binding = new Binding("Test") { Mode = BindingMode.TwoWay };
|
||||
window.SetBinding(Window.TitleProperty, binding);
|
||||
this.viewManager.Setup(x => x.CreateAndBindViewForModel(model)).Returns(window);
|
||||
|
||||
this.windowManager.CreateWindow(model, false);
|
||||
|
||||
var e = window.GetBindingExpression(Window.TitleProperty);
|
||||
Assert.AreEqual("Test", e.ParentBinding.Path.Path);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateWindowActivatesViewModel()
|
||||
{
|
||||
|
@ -285,7 +316,7 @@ namespace StyletUnitTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void SetsWindowStartupLocationToCenterScreenIfThereIsNoOwnerAndItHasNotBeenSetAlready()
|
||||
public void CreateWindowSetsWindowStartupLocationToCenterScreenIfThereIsNoOwnerAndItHasNotBeenSetAlready()
|
||||
{
|
||||
var model = new object();
|
||||
var window = new Window();
|
||||
|
@ -297,7 +328,7 @@ namespace StyletUnitTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void DoesNotSetStartupLocationIfItIsNotManual()
|
||||
public void CreateWindowDoesNotSetStartupLocationIfItIsNotManual()
|
||||
{
|
||||
var model = new object();
|
||||
var window = new Window();
|
||||
|
@ -310,7 +341,7 @@ namespace StyletUnitTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void DoesNotSetStartupLocationIfLeftSet()
|
||||
public void CreateWindowDoesNotSetStartupLocationIfLeftSet()
|
||||
{
|
||||
var model = new object();
|
||||
var window = new Window();
|
||||
|
@ -323,7 +354,7 @@ namespace StyletUnitTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void DoesNotSetStartupLocationIfTopSet()
|
||||
public void CreateWindowDoesNotSetStartupLocationIfTopSet()
|
||||
{
|
||||
var model = new object();
|
||||
var window = new Window();
|
||||
|
|
Loading…
Reference in New Issue