ClipboardCopyMode="IncludeHeader"in the XAML of the DataGrid.
Showing posts with label wpf. Show all posts
Showing posts with label wpf. Show all posts
Wednesday, May 11, 2011
WPF copy/paste column names on DataGrid
I always forget that you can easily include column names when copying a DataGrid by setting
Labels:
programming,
wpf
Monday, November 15, 2010
WPF ComboBox and XAML parser
For the past few days I have been trying to figure out why my ComboBox didn't work when I selected an item from a list of data-bound items. I've gone through the code over and over, tried different types of collections and different ways of accessing the selected item (SelectedValue or SelectedItem as int, string or object). Nothing worked.
Data-binding to a ComboBox in WPF/Silverlight isn't always as smooth as one would assume. People have problems here, here and there. The XAML was fairly easy to lay out, I thought. I had:
It wasn't until I read "I always set the ItemSource before the SelectedItem and all works fine." that I thought I'd try switching my code to:
This way I define ItemsSource before SelectedItem. However, I never thought for a second that the XAML parser would care. I assumed the parser would figure out that it needs to know about the collection before it cared about what was selected. Obviously, if this were c# code I'd always specify the collection first, but this was XML, what does it care about the order of attributes?
I had broken the first rule of programming, never assume.
Data-binding to a ComboBox in WPF/Silverlight isn't always as smooth as one would assume. People have problems here, here and there. The XAML was fairly easy to lay out, I thought. I had:
<ComboBox SelectedItem="{Binding Path=ReferenceType}"
ItemsSource="{Binding Path=ReferenceTypes}" />
It wasn't until I read "I always set the ItemSource before the SelectedItem and all works fine." that I thought I'd try switching my code to:
<ComboBox ItemsSource="{Binding Path=ReferenceTypes}"
SelectedItem="{Binding Path=ReferenceType}" />
This way I define ItemsSource before SelectedItem. However, I never thought for a second that the XAML parser would care. I assumed the parser would figure out that it needs to know about the collection before it cared about what was selected. Obviously, if this were c# code I'd always specify the collection first, but this was XML, what does it care about the order of attributes?
I had broken the first rule of programming, never assume.
Labels:
programming,
wpf
Monday, August 30, 2010
WPF, TextBox and currency
Getting data to look right in WPF can be a bit tricky. I wanted integers to appear as currency, but without any decimal points. After a bit of stuffing around I went from:
<TextBox Text="StringFormat=C}" />to
<TextBox Text="StringFormat=\{0:$###\,##0\}}" />
Labels:
wpf
Wednesday, August 4, 2010
Subversion
I have decided to hide subversive quotes in the software I am working on.
If you find them all, you unlock "The Revolution Complete" achievement.

Labels:
communism,
programming,
revolution,
wpf
Thursday, July 1, 2010
ToolTips and ShowDuration
This took me a while to figure out, so I thought I'd mention it for others searching. If you want to set a global ToolTip show duration in WPF, you can do it for each type of control as a style in the XAML file. E.g.
This means that for the Window, all the Label ToolTips will remain for two minutes.
If you want good looking ToolTips, go here.
<Window.Resources>
<Style TargetType="Label">
<Setter Property="ToolTipService.ShowDuration" Value="120000" />
</Style>
</Window.Resources>
This means that for the Window, all the Label ToolTips will remain for two minutes.
If you want good looking ToolTips, go here.
Labels:
programming,
wpf
Subscribe to:
Posts (Atom)