<ListView.View> <GridView> <GridViewColumn Header="Address"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0}, {1}"> <Binding Path="Address.City"/> <Binding Path="Address.State"/> </MultiBinding> </TextBlock.Text> </TextBlock> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> ... ... ...
9/16/10
Binding multiple properties to one XAML element using WPF MultiBinding
9/13/10
ListView SelectedItem color and Alternate row background
Lots of examples on how to change ListView SelectedItem color will overwrite the System.Colors.HighlightBrushKey and SystemColors.ControlBrushKey:
MSDN shows example:
Which will not work for my trigger (since I am using a Border the ControlTemplate). So instead of operating directly on ItemControl.AlternationIndex, I change the background of a different element - Border.
<Style x:Key="myListboxStyle"> <Style.Resources> <!-- Background of selected item when focussed --> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Red" /> <!-- Background of selected item when not focussed --> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Green" /> </Style.Resources> </Style>You can argue whether that's elegant or not, I just didn't want to do that, so below is a slightly different aproach: I create my own element (Border in this case) and change it's color. Also jammed into here alternate background triggers.
<ListView ItemContainerStyle="{StaticResource ListViewItemStyle}" AlternationCount="2" />
<Style x:Key="ListViewItemStyle" TargetType="ListViewItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBoxItem"> <Border x:Name="Border" SnapsToDevicePixels="true"> <GridViewRowPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="true"> <Setter TargetName="Border" Property="Background" Value="Blue"/> </Trigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="false"/> <Condition Property="ItemsControl.AlternationIndex" Value="1"/> </MultiTrigger.Conditions> <Setter TargetName="Border" Property="Background" Value="WhiteSmoke"/> </MultiTrigger> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="false"/> <Condition Property="ItemsControl.AlternationIndex" Value="2"/> </MultiTrigger.Conditions> <Setter TargetName="Border" Property="Background" Value="White"/> </MultiTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
MSDN shows example:
<Trigger Property="ItemsControl.AlternationIndex" Value="1"> <Setter Property="Background" Value="WhiteSmoke"></Setter> </Trigger> <Trigger Property="ItemsControl.AlternationIndex" Value="2"> <Setter Property="Background" Value="White"></Setter> </Trigger>
Which will not work for my trigger (since I am using a Border the ControlTemplate). So instead of operating directly on ItemControl.AlternationIndex, I change the background of a different element - Border.
7/16/10
good old quote
I was looking through my grammars book by Daniel I.A.Cohem "Introduction to Computer Theory". Chapter 16 goes into depth on Pushdown Automata Theory with Chomsky Normal Form.
Theorem 21
If L is a context-free language generated by a Context -free Grammar that includes A-productions, then there is a different context=free grammar that has no A-productions that generates either the whole language L or else generates the language of all the words in L that are not A.
If you never took grammars and after reading this were like what the..? A few pages later in the end of the proof, the author throws this great metaphor to help you understand the rules. I read it again and couldn't help laughing ...and enjoying:
Those never born need never die.
First statistician:
" With all the trouble in this world, it would be better if we were never born in the first place."
Second statistician:
"Yes, but how many are so lucky? Maybe one in ten thousand."
Theorem 21
If L is a context-free language generated by a Context -free Grammar that includes A-productions, then there is a different context=free grammar that has no A-productions that generates either the whole language L or else generates the language of all the words in L that are not A.
If you never took grammars and after reading this were like what the..? A few pages later in the end of the proof, the author throws this great metaphor to help you understand the rules. I read it again and couldn't help laughing ...and enjoying:
Those never born need never die.
First statistician:
" With all the trouble in this world, it would be better if we were never born in the first place."
Second statistician:
"Yes, but how many are so lucky? Maybe one in ten thousand."
Subscribe to:
Posts (Atom)