Skip to content

Instantly share code, notes, and snippets.

[TemplatePart(Name = "PART_OverlayAdorner", Type = typeof(AdornerDecorator))]
public class Overlay : ContentControl
{
public static readonly DependencyProperty OverlayContentProperty =
DependencyProperty.Register("OverlayContent", typeof(UIElement), typeof(Overlay),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnOverlayContentChanged)));
public static readonly DependencyProperty IsOverlayContentVisibleProperty =
DependencyProperty.Register("IsOverlayContentVisible", typeof(bool), typeof(Overlay),
new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsOverlayContentVisibleChanged)));
<Style TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<Border SnapsToDevicePixels="true"
Application.Current.Resources = Application.LoadComponent(
new Uri("Company.MyAppliction;component/Themes/MyImplicitStyles.xaml", UriKind.Relative))
as ResourceDictionary;
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="MyImplicitStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<ListBox>
<ListBox.Template>
<ControlTemplate TargetType="{x:Type ListBox}">
<Border x:Name="Bd" SnapsToDevicePixels="true"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="1">
<Grid>
<Image HorizontalAlignment="Right"
// Found binding error
FrameworkElement element = parent as FrameworkElement;
if (element != null)
{
var elementAdornerLayer = AdornerLayer.GetAdornerLayer(element);
Adorner[] adorners = elementAdornerLayer.GetAdorners(element);
if (adorners != null)
{
foreach (Adorner a in adorners)
public static void CheckForBindingErrors(DependencyObject parent)
{
// Examine parent for binding errors
LocalValueEnumerator localValues = parent.GetLocalValueEnumerator();
while (localValues.MoveNext())
{
LocalValueEntry entry = localValues.Current;
if (BindingOperations.IsDataBound(parent, entry.Property))
{
BindingExpression binding =
public static class ViewModelBehavior
{
public static readonly DependencyProperty LoadUnloadProperty =
DependencyProperty.RegisterAttached("LoadUnload", typeof(Boolean),
typeof(ViewModelBehavior),
new FrameworkPropertyMetadata(false,
new PropertyChangedCallback(OnLoadUnloadChanged)));
public static void SetLoadUnload(FrameworkElement element, Boolean value)
{
public interface IViewModel : INotifyPropertyChanged
{
bool Initialized { get; set; }
void Load(FrameworkElement element);
void Unload(FrameworkElement element);
}
cbuffer CB
{
matrix View;
matrix Projection;
matrix ViewProjection;
float4 FrustumPlanes[6]; // view-frustum planes in world space (normals face out)
float2 ViewportSize; // Viewport Width and Height in pixels