How to perform Single click checkbox selection in WPF DataGrid?

For single click DataGrid checkbox you can just put regular checkbox control inside DataGridTemplateColumn and set UpdateSourceTrigger=PropertyChanged. <DataGridTemplateColumn.CellTemplate> <DataTemplate> <CheckBox IsChecked=”{Binding Path=IsSelected, UpdateSourceTrigger=PropertyChanged}” /> </DataTemplate> </DataGridTemplateColumn.CellTemplate>

WPF: Grid with column/row margin/padding?

RowDefinition and ColumnDefinition are of type ContentElement, and Margin is strictly a FrameworkElement property. So to your question, “is it easily possible” the answer is a most definite no. And no, I have not seen any layout panels that demonstrate this kind of functionality. You can add extra rows or columns as you suggested. But … Read more

Difference between Label and TextBlock

TextBlock is not a control Even though TextBlock lives in the System.Windows.Controls namespace, it is not a control. It derives directly from FrameworkElement. Label, on the other hand, derives from ContentControl. This means that Label can: Be given a custom control template (via the Template property). Display data other than just a string (via the … Read more

WPF: Setting the Width (and Height) as a Percentage Value

You can put the textboxes inside a grid to do percentage values on the rows or columns of the grid and let the textboxes auto-fill to their parent cells (as they will by default). Example: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=”2*” /> <ColumnDefinition Width=”3*” /> </Grid.ColumnDefinitions> <TextBox Grid.Column=”0″ /> <TextBox Grid.Column=”1″ /> </Grid> This will make #1 … Read more

What is so special about Generic.xaml?

Every Control in WPF has a default Style that provides, among other things, the Control’s default ControlTemplate. WPF looks for the default style in a special resource dictionary in the Themes folder in the same assembly as the control. The key for the default style is provided by the Control.DefaultStyleKey dependency property, the default value … Read more

Align items in a stack panel?

You can achieve this with a DockPanel: <DockPanel Width=”300″> <TextBlock>Left</TextBlock> <Button HorizontalAlignment=”Right”>Right</Button> </DockPanel> The difference is that a StackPanel will arrange child elements into single line (either vertical or horizontally) whereas a DockPanel defines an area where you can arrange child elements either horizontally or vertically, relative to each other (the Dock property changes the … Read more

Passing two command parameters using a WPF binding

Firstly, if you’re doing MVVM you would typically have this information available to your VM via separate properties bound from the view. That saves you having to pass any parameters at all to your commands. However, you could also multi-bind and use a converter to create the parameters: <Button Content=”Zoom” Command=”{Binding MyViewModel.ZoomCommand”> <Button.CommandParameter> <MultiBinding Converter=”{StaticResource … Read more

WPF TemplateBinding vs RelativeSource TemplatedParent

TemplateBinding is not quite the same thing. MSDN docs are often written by people that have to quiz monosyllabic SDEs about software features, so the nuances are not quite right. TemplateBindings are evaluated at compile time against the type specified in the control template. This allows for much faster instantiation of compiled templates. Just fumble … Read more

Binding ConverterParameter

The ConverterParameter property can not be bound because it is not a dependency property. Since Binding is not derived from DependencyObject none of its properties can be dependency properties. As a consequence, a Binding can never be the target object of another Binding. There is however an alternative solution. You could use a MultiBinding with … Read more

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>

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