12 changed files with 198 additions and 35 deletions
@ -0,0 +1,43 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="ContentControl.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Controls |
|||
{ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
public class HeaderedContentControl : ContentControl, ILogical, IHeadered |
|||
{ |
|||
public static readonly PerspexProperty<object> HeaderProperty = |
|||
PerspexProperty.Register<ContentControl, object>("Header"); |
|||
|
|||
public object Header |
|||
{ |
|||
get { return this.GetValue(HeaderProperty); } |
|||
set { this.SetValue(HeaderProperty, value); } |
|||
} |
|||
|
|||
IEnumerable<ILogical> ILogical.LogicalChildren |
|||
{ |
|||
get |
|||
{ |
|||
ILogical logicalContent = this.Content as ILogical; |
|||
ILogical logicalHeader = this.Header as ILogical; |
|||
|
|||
if (logicalContent != null) |
|||
{ |
|||
yield return logicalContent; |
|||
} |
|||
|
|||
if (logicalHeader != null) |
|||
{ |
|||
yield return logicalHeader; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Perspex.Controls |
|||
{ |
|||
public class Tab : ContentControl |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="TabStrip.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Controls |
|||
{ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
|
|||
public class TabStrip : ItemsControl |
|||
{ |
|||
private static readonly DataTemplate TabTemplate = new DataTemplate(_ => true, CreateTab); |
|||
|
|||
protected override DataTemplate FindDataTemplate(object content) |
|||
{ |
|||
return TabTemplate; |
|||
} |
|||
|
|||
private static IVisual CreateTab(object o) |
|||
{ |
|||
return new Tab { Content = o }; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="IHeadered.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex |
|||
{ |
|||
public interface IHeadered |
|||
{ |
|||
object Header { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="TabStripStyle.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Themes.Default |
|||
{ |
|||
using System.Linq; |
|||
using Perspex.Controls; |
|||
using Perspex.Media; |
|||
using Perspex.Styling; |
|||
|
|||
public class TabStripStyle : Styles |
|||
{ |
|||
public TabStripStyle() |
|||
{ |
|||
this.AddRange(new[] |
|||
{ |
|||
new Style(x => x.OfType<TabStrip>()) |
|||
{ |
|||
Setters = new[] |
|||
{ |
|||
new Setter(Button.TemplateProperty, ControlTemplate.Create<TabStrip>(this.Template)), |
|||
}, |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
private Control Template(TabStrip control) |
|||
{ |
|||
return new ItemsPresenter |
|||
{ |
|||
ItemsPanel = new ItemsPanelTemplate(() => new StackPanel()), |
|||
[~ItemsPresenter.ItemsProperty] = control[~ItemsControl.ItemsProperty], |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="TabStyle.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Themes.Default |
|||
{ |
|||
using System.Linq; |
|||
using Perspex.Controls; |
|||
using Perspex.Media; |
|||
using Perspex.Styling; |
|||
|
|||
public class TabStyle : Styles |
|||
{ |
|||
public TabStyle() |
|||
{ |
|||
this.AddRange(new[] |
|||
{ |
|||
new Style(x => x.OfType<Tab>()) |
|||
{ |
|||
Setters = new[] |
|||
{ |
|||
new Setter(Button.TemplateProperty, ControlTemplate.Create<Tab>(this.Template)), |
|||
}, |
|||
}, |
|||
}); |
|||
} |
|||
|
|||
private Control Template(Tab control) |
|||
{ |
|||
return new Border |
|||
{ |
|||
Background = Brushes.Red, |
|||
Content = new ContentPresenter |
|||
{ |
|||
[~ContentPresenter.ContentProperty] = control[~Tab.ContentProperty], |
|||
} |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue