Is there a way to comment out XAML that contains comments?

No, there is no way of having nested comments in XAML. You could use the mc:Ignorable attribute on your root element, and any attribute or element prefixed with that value will be ignored E.g: <UserControl … mc:Ignorable=”i”> <!– Ignore Text attribute –> <TextBlock i:Text=”Hello” /> <!– Ignore entire button –> <i:Button> </i:Button> </UserControl> Note that … Read more

WPF Label Foreground Color

I checked your XAML, it works fine – e.g. both labels have a gray foreground. My guess is that you have some style which is affecting the way it looks… Try moving your XAML to a brand-new window and see for yourself… Then, check if you have any themes or styles (in the Window.Resources for … Read more

WPF Datatrigger not firing when expected

Alternatively, you could replace your XAML with this: <TextBlock Margin=”0,0,5,0″ Text=”{Binding ElementName=EditListBox, Path=SelectedItems.Count}”/> <TextBlock> <TextBlock.Style> <Style TargetType=”{x:Type TextBlock}”> <Setter Property=”Text” Value=”items selected”/> <Style.Triggers> <DataTrigger Binding=”{Binding ElementName=EditListBox, Path=SelectedItems.Count}” Value=”1″> <Setter Property=”Text” Value=”item selected”/> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> Converters can solve a lot of binding problems but having a lot of specialized converters gets very messy.

How does ItemContainerGenerator.ContainerFromItem work with a grouped list?

You have to listen and react to the ItemsGenerator.StatusChanged Event and wait until the ItemContainers are generated before you can access them with ContainerFromElement. Searching further, I’ve found a thread in the MSDN forum from someone who has the same problem. This seems to be a bug in WPF, when one has a GroupStyle set. … Read more

WPF Trigger when property value is greater than a certain amount

You can use a data trigger and set the binding RelativeSource to Self. Data Triggers allow binding and bindings lets you have converters. Example: <Button Content=”I change colour depending on my width for some reason”> <Button.Triggers> <DataTrigger Binding=”{Binding Path=Width, RelativeSource={RelativeSource Self}, Converter={StaticResource isLessThanConverter}, ConverterParameter=50}” Value=”True”> <Setter Property=”Button.Background” Value=”Red” /> <DataTrigger> <Button.Triggers> <Button> Reference