Click here to Skip to main content
15,911,890 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Quick Binding Question Pin
Kevin Marois28-Mar-12 11:17
professionalKevin Marois28-Mar-12 11:17 
GeneralRe: Quick Binding Question Pin
SledgeHammer0128-Mar-12 12:15
SledgeHammer0128-Mar-12 12:15 
QuestionWPF Splitter Not Working Pin
Kevin Marois28-Mar-12 6:59
professionalKevin Marois28-Mar-12 6:59 
AnswerRe: WPF Splitter Not Working Pin
Gerry Schmitz28-Mar-12 14:12
mveGerry Schmitz28-Mar-12 14:12 
Questionbinding text and 2 radio buttons Pin
Sutton Mehaffey28-Mar-12 5:37
Sutton Mehaffey28-Mar-12 5:37 
Questionwpf 3d with lots of models Pin
soheilvb28-Mar-12 5:26
soheilvb28-Mar-12 5:26 
AnswerRe: wpf 3d with lots of models Pin
Pete O'Hanlon28-Mar-12 5:56
mvePete O'Hanlon28-Mar-12 5:56 
QuestionHow to localize a DatePicker? Pin
Bernhard Hiller28-Mar-12 0:46
Bernhard Hiller28-Mar-12 0:46 
AnswerRe: How to localize a DatePicker? Pin
Bernhard Hiller28-Mar-12 19:57
Bernhard Hiller28-Mar-12 19:57 
GeneralRe: How to localize a DatePicker? Pin
Mycroft Holmes28-Mar-12 21:54
professionalMycroft Holmes28-Mar-12 21:54 
QuestionAnother Expander Style Question Pin
Kevin Marois27-Mar-12 8:14
professionalKevin Marois27-Mar-12 8:14 
AnswerRe: Another Expander Style Question Pin
Mycroft Holmes27-Mar-12 12:57
professionalMycroft Holmes27-Mar-12 12:57 
GeneralRe: Another Expander Style Question Pin
SledgeHammer0127-Mar-12 13:21
SledgeHammer0127-Mar-12 13:21 
GeneralRe: Another Expander Style Question Pin
Mycroft Holmes27-Mar-12 14:12
professionalMycroft Holmes27-Mar-12 14:12 
AnswerRe: Another Expander Style Question Pin
SledgeHammer0127-Mar-12 13:20
SledgeHammer0127-Mar-12 13:20 
GeneralRe: Another Expander Style Question Pin
Kevin Marois27-Mar-12 13:24
professionalKevin Marois27-Mar-12 13:24 
QuestionUnable to catch Key.Down in a combox with applied style Pin
George Nistor26-Mar-12 23:31
George Nistor26-Mar-12 23:31 
QuestionWPF Styling/Templating Problem Pin
Kevin Marois26-Mar-12 14:14
professionalKevin Marois26-Mar-12 14:14 
I styled an expander control. I then templated a ListView so that each ListViewItem is the expander.

The problem is that the expander doesn't fill up to the width of the list. It only appears as wide as the expander's content.

Ok, here's the XAML. I know it's alot but I thought you may want to copy & paste to see what it does. Can anyone see why the list items don't sie properly?

<Window.Resources>

    <!--Colors-->
    <Color x:Key="Color1">Gray</Color>
    <Color x:Key="Color2">SlateGray</Color>
    <Color x:Key="Color3">DarkSlateGray</Color>
    <Color x:Key="Color4">Orange</Color>
    <Color x:Key="HeaderGradientBrush1">DarkGray</Color>
    <Color x:Key="HeaderGradientBrush2">White</Color>

    <!--Brushes-->
    <SolidColorBrush x:Key="ToggleButtonEllipseBorderBrush"
                        Color="{StaticResource Color1}" />
    <SolidColorBrush x:Key="ToggleButtonArrowBrush"
                        Color="{StaticResource Color2}" />
    <SolidColorBrush x:Key="ToggleButtonUpArrowBrush"
                        Color="{StaticResource Color4}" />
    <SolidColorBrush x:Key="ToggleButtonRectangleBrush"
                        Color="{StaticResource Color2}" />
    <SolidColorBrush x:Key="ToggleButtonBackgroundBrush"
                        Color="Transparent" />
    <SolidColorBrush x:Key="ContentAreaBackgroundBrush"
                        Color="White" />
    <SolidColorBrush x:Key="ContentAreaBorderBrush"
                        Color="{StaticResource Color3}" />
    <SolidColorBrush x:Key="CardSeperatorBorderBrush"
                        Color="{StaticResource Color3}" />
    <SolidColorBrush x:Key="ExpanderBorderBrush"
                        Color="{StaticResource Color1}" />
    <SolidColorBrush x:Key="ExpanderHeaderTextColor"
                        Color="{StaticResource Color3}" />
    <LinearGradientBrush x:Key="headerGradientBrush"
                            EndPoint="0.504,1.5"
                            StartPoint="0.504,0.03">
        <GradientStop Color="{StaticResource HeaderGradientBrush1}"
                        Offset="0" />
        <GradientStop Color="{StaticResource HeaderGradientBrush2}"
                        Offset="0.567" />
    </LinearGradientBrush>

    <!--Control template for the Toggle Button-->
    <ControlTemplate x:Key="ExpanderToggleButton"
                        TargetType="{x:Type ToggleButton}">

        <Grid Width="16"
                Height="16">

            <Path x:Name="UpperArrow"
                    Stroke="{StaticResource ToggleButtonArrowBrush}"
                    StrokeThickness="2"
                    Data="M 3,4 l 5,5 5,-5" />

            <Path x:Name="LowerArrow"
                    Stroke="{StaticResource ToggleButtonArrowBrush}"
                    StrokeThickness="2"
                    Data="M 3,9 l 5,5 5,-5" />

            <ContentPresenter VerticalAlignment="Center"
                                HorizontalAlignment="Center"
                                Content="{TemplateBinding Content}" />
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsChecked"
                        Value="true">
                <Setter Property="Data"
                        TargetName="UpperArrow"
                        Value="M 3,9 l 5,-5 5,5" />
                <Setter Property="Data"
                        TargetName="LowerArrow"
                        Value="M 3,6 l 5,-5 5,5" />
                <Setter Property="Stroke"
                        TargetName="UpperArrow"
                        Value="{StaticResource ToggleButtonUpArrowBrush}" />
                <Setter Property="Stroke"
                        TargetName="LowerArrow"
                        Value="{StaticResource ToggleButtonUpArrowBrush}" />
            </Trigger>
            <Trigger Property="IsMouseOver"
                        Value="true">
                <Setter Property="Stroke"
                        TargetName="UpperArrow"
                        Value="{StaticResource ToggleButtonUpArrowBrush}" />
                <Setter Property="Stroke"
                        TargetName="LowerArrow"
                        Value="{StaticResource ToggleButtonUpArrowBrush}" />
            </Trigger>
        </ControlTemplate.Triggers>


    </ControlTemplate>

    <!-- Expander style -->
    <Style x:Key="ContactCardExpanderStyle" 
            TargetType="Expander">

        <Setter Property="Foreground"
                Value="{StaticResource ExpanderHeaderTextColor}" />

        <Setter Property="Template">
            <Setter.Value>

                <!-- Control template for Expander -->
                <ControlTemplate TargetType="Expander">
                    <Grid>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Name="ContentRow"
                                            Height="0" />
                        </Grid.RowDefinitions>

                        <!--Header Area-->
                        <Border Name="Border"
                                Grid.Row="0"
                                Background="{StaticResource headerGradientBrush}"
                                BorderBrush="{StaticResource ExpanderBorderBrush}"
                                BorderThickness="1">

                            <Grid>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="20" />
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="20" />
                                </Grid.ColumnDefinitions>

                                <!--Left Rectangle-->
                                <Rectangle x:Name="LeftPanel"
                                            Grid.Row="0"
                                            Fill="{StaticResource ExpanderBorderBrush}"
                                            Width="10"
                                            Margin="2"
                                            HorizontalAlignment="Left" />

                                <!--Toggle Button-->
                                <ToggleButton Grid.Column="2"
                                                IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                OverridesDefaultStyle="True"
                                                Template="{StaticResource ExpanderToggleButton}"
                                                Background="{StaticResource ToggleButtonBackgroundBrush}" />

                                <!--Caption-->
                                <ContentPresenter Grid.Column="1"
                                                    Margin="5"
                                                    ContentSource="Header"
                                                    RecognizesAccessKey="True" />
                            </Grid>

                        </Border>

                        <!--Content Area-->
                        <Border Name="Content"
                                Grid.Row="1"
                                Background="{StaticResource ContentAreaBackgroundBrush}"
                                BorderBrush="{StaticResource ExpanderBorderBrush}"
                                BorderThickness="1,0,1,1"
                                CornerRadius="0,0,3,3">

                            <ContentPresenter Margin="4" />

                        </Border>

                    </Grid>

                    <ControlTemplate.Triggers>

                        <!--This sets the foreground text to orange when the mouse is over
                        the control and the control is NOT expanded-->
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver"
                                            Value="True" />
                                <Condition Property="IsExpanded"
                                            Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter Property="Foreground"
                                    Value="{StaticResource ToggleButtonUpArrowBrush}" />
                            <Setter TargetName="LeftPanel"
                                    Property="Fill"
                                    Value="{StaticResource ToggleButtonUpArrowBrush}" />
                        </MultiTrigger>

                        <!--This sets the arrow and rectangle colors to orange when the mouse
                        is over the control and the control IS expanded-->
                        <Trigger Property="IsExpanded"
                                    Value="True">

                            <Setter TargetName="ContentRow"
                                    Property="Height"
                                    Value="{Binding ElementName=Content,Path=DesiredHeight}" />
                            <Setter TargetName="Border"
                                    Property="BorderBrush"
                                    Value="{StaticResource ExpanderBorderBrush}" />
                            <Setter TargetName="LeftPanel"
                                    Property="Fill"
                                    Value="{StaticResource ToggleButtonUpArrowBrush}" />

                        </Trigger>

                    </ControlTemplate.Triggers>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

    <!--List Item Template-->
    <DataTemplate x:Key="contactCardTemplate">

        <Expander Style="{StaticResource ContactCardExpanderStyle}"
                    Header="{Binding DisplayName}"
                    Margin="2,2.5,2,2.5">
                
                

        </Expander>
    
    </DataTemplate>

</Window.Resources>

<Grid x:Name="LayoutRoot">
        
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>      <!--Menu Row-->
        <RowDefinition Height="Auto" />     <!--Toolbar Row-->
        <RowDefinition Height="*" />        <!--Main Content Row-->
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />   <!--Contacts Column-->
        <ColumnDefinition Width="*" />      <!--Contact Info Column-->
        <ColumnDefinition Width="*" />      <!--Right Panel Column-->
    </Grid.ColumnDefinitions>
        
    <!--Left side contacts list grid-->
    <Grid x:Name="ContactsListGrid"
            Grid.Row="2"
            Grid.Column="0">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />     <!--Options Expander Row-->
            <RowDefinition Height="*" />        <!--Contacts List-->
        </Grid.RowDefinitions>

        <!--Contacts List-->
        <ListView x:Name="ContactsList"
                    Grid.Row="1"
                    ItemsSource="{Binding Contacts}"
                    SelectedItem="{Binding SelectedContact, Mode=TwoWay}"
                    BorderBrush="{StaticResource ContentAreaBorderBrush}"
                    ItemTemplate="{StaticResource contactCardTemplate}"
                    Margin="3" />
    </Grid>
        
</Grid>

Everything makes sense in someone's mind

AnswerRe: WPF Styling/Templating Problem Pin
Abhinav S26-Mar-12 15:21
Abhinav S26-Mar-12 15:21 
GeneralRe: WPF Styling/Templating Problem Pin
Kevin Marois27-Mar-12 6:17
professionalKevin Marois27-Mar-12 6:17 
Questionhow to design Bubble chart with Datapoints like Piechart Pin
Tryxo26-Mar-12 12:11
Tryxo26-Mar-12 12:11 
QuestionMerge cells in C1Flexgrid for WPF Pin
Greeshma M J25-Mar-12 22:42
Greeshma M J25-Mar-12 22:42 
AnswerRe: Merge cells in C1Flexgrid for WPF Pin
Pete O'Hanlon26-Mar-12 0:06
mvePete O'Hanlon26-Mar-12 0:06 
QuestionXamDataGrid columns Pin
michaelgr125-Mar-12 22:22
michaelgr125-Mar-12 22:22 
GeneralRe: XamDataGrid columns Pin
michaelgr126-Mar-12 7:03
michaelgr126-Mar-12 7:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.