DataTrigger where value is NOT null?

This is a bit of a cheat but I just set a default style and then overrode it using a DataTrigger if the value is null… <Style> <!– Highlight for Reviewed (Default) –> <Setter Property=”Control.Background” Value=”PaleGreen” /> <Style.Triggers> <!– Highlight for Not Reviewed –> <DataTrigger Binding=”{Binding Path=REVIEWEDBY}” Value=”{x:Null}”> <Setter Property=”Control.Background” Value=”LightIndianRed” /> </DataTrigger> </Style.Triggers> </Style>

How to make overlay control above all other controls?

If you are using a Canvas or Grid in your layout, give the control to be put on top a higher ZIndex. From MSDN: <Page xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” WindowTitle=”ZIndex Sample”> <Canvas> <Rectangle Canvas.ZIndex=”3″ Width=”100″ Height=”100″ Canvas.Top=”100″ Canvas.Left=”100″ Fill=”blue”/> <Rectangle Canvas.ZIndex=”1″ Width=”100″ Height=”100″ Canvas.Top=”150″ Canvas.Left=”150″ Fill=”yellow”/> <Rectangle Canvas.ZIndex=”2″ Width=”100″ Height=”100″ Canvas.Top=”200″ Canvas.Left=”200″ Fill=”green”/> <!– Reverse the order to … Read more

Binding to static property

If the binding needs to be two-way, you must supply a path. There’s a trick to do two-way binding on a static property, provided the class is not static : declare a dummy instance of the class in the resources, and use it as the source of the binding. <Window.Resources> <local:VersionManager x:Key=”versionManager”/> </Window.Resources> … <TextBox … Read more

How to bind an enum to a combobox control in WPF?

You can do it from code by placing the following code in Window Loaded event handler, for example: yourComboBox.ItemsSource = Enum.GetValues(typeof(EffectStyle)).Cast<EffectStyle>(); If you need to bind it in XAML you need to use ObjectDataProvider to create object available as binding source: <Window x:Class=”YourNamespace.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:System=”clr-namespace:System;assembly=mscorlib” xmlns:StyleAlias=”clr-namespace:Motion.VideoEffects”> <Window.Resources> <ObjectDataProvider x:Key=”dataFromEnum” MethodName=”GetValues” ObjectType=”{x:Type System:Enum}”> <ObjectDataProvider.MethodParameters> <x:Type … Read more

How do I space out the child elements of a StackPanel?

Use Margin or Padding, applied to the scope within the container: <StackPanel> <StackPanel.Resources> <Style TargetType=”{x:Type TextBox}”> <Setter Property=”Margin” Value=”0,10,0,0″/> </Style> </StackPanel.Resources> <TextBox Text=”Apple”/> <TextBox Text=”Banana”/> <TextBox Text=”Cherry”/> </StackPanel> EDIT: In case you would want to re-use the margin between two containers, you can convert the margin value to a resource in an outer scope, f.e. … Read more

How to hide close button in WPF window?

WPF doesn’t have a built-in property to hide the title bar’s Close button, but you can do it with a few lines of P/Invoke. First, add these declarations to your Window class: private const int GWL_STYLE = -16; private const int WS_SYSMENU = 0x80000; [DllImport(“user32.dll”, SetLastError = true)] private static extern int GetWindowLong(IntPtr hWnd, int … Read more

Properties order in Margin

Margin=”1,2,3,4″ Left, Top, Right, Bottom It is also possible to specify just two sizes like this: Margin=”1,2″ Left AND right Top AND bottom Finally you can specify a single size: Margin=”1″ used for all sides The order is the same as in WinForms.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)