Create a menu Bar in WPF?

<DockPanel> <Menu DockPanel.Dock=”Top”> <MenuItem Header=”_File”> <MenuItem Header=”_Open”/> <MenuItem Header=”_Close”/> <MenuItem Header=”_Save”/> </MenuItem> </Menu> <StackPanel></StackPanel> </DockPanel>

Forcing a WPF tooltip to stay on the screen

If you want to set this for just one tooltip, set the duration on the object having the Tooltip, like this: <Label ToolTipService.ShowDuration=”12000″ Name=”lblShowTooltip” Content=”Shows tooltip”> <Label.ToolTip> <ToolTip> <TextBlock>Hello world!</TextBlock> </ToolTip> </Label.ToolTip> </Label> I’d say that this design was chosen because it allows same tooltip with different timeouts on different controls. If you want this … Read more

Is there a way to chain multiple value converters in XAML?

I used this method by Gareth Evans in my Silverlight project. Here’s my implementation of it: public class ValueConverterGroup : List<IValueConverter>, IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture)); } public object ConvertBack(object value, Type targetType, object parameter, … Read more

How can I set the color of a selected row in DataGrid

The above solution left blue border around each cell in my case. This is the solution that worked for me. It is very simple, just add this to your DataGrid. You can change it from a SolidColorBrush to any other brush such as linear gradient. <DataGrid.Resources> <SolidColorBrush x:Key=”{x:Static SystemColors.HighlightBrushKey}” Color=”#FF0000″/> </DataGrid.Resources>

Pan & Zoom Image

After using samples from this question I’ve made complete version of pan & zoom app with proper zooming relative to mouse pointer. All pan & zoom code has been moved to separate class called ZoomBorder. ZoomBorder.cs using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; namespace PanAndZoom { public class ZoomBorder : Border { … Read more

Binding a Button’s visibility to a bool value in ViewModel

Assuming AdvancedFormat is a bool, you need to declare and use a BooleanToVisibilityConverter: <!– In your resources section of the XAML –> <BooleanToVisibilityConverter x:Key=”BoolToVis” /> <!– In your Button declaration –> <Button Height=”50″ Width=”50″ Style=”{StaticResource MyButtonStyle}” Command=”{Binding SmallDisp}” CommandParameter=”{Binding}” Cursor=”Hand” Visibility=”{Binding Path=AdvancedFormat, Converter={StaticResource BoolToVis}}”/> Note the added Converter={StaticResource BoolToVis}. This is a very common pattern … Read more

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