0

I am developing wpf applications. I want to remove expander circular icon. Below is my expander code. Thanks in advance.I also want to remove CornerRadius

<Expander x:Name="Expander" HorizontalAlignment="Right" FlowDirection="RightToLeft"    Foreground="White" FontFamily="segoe_uilight"  Width="200px"    BorderBrush="#FF0A0909" BorderThickness="1,1,1,2" Background="#99080707" >
            <Expander.Header>
                <StackPanel Orientation="Horizontal">

                    <Canvas Height="22" Width="172px" VerticalAlignment="Bottom">

                      // here is some code
                    </Canvas>
                </StackPanel>
            </Expander.Header>

            <!--<Expander.Content>
                <TextBox Text="LoginUserName"></TextBox>
            </Expander.Content>-->
            <StackPanel Margin="10,4,0,0"  >
                <StackPanel Orientation="Horizontal" Height="35">

                   // Here is some code

                </StackPanel>
                <!--<Label Margin="4" Content="Logout"  />-->
                <!--<Button x:Name="btnLogout" Margin="4" Content="Logout" Click="btnLogout_Click_1"></Button>-->

                <StackPanel Orientation="Horizontal" Height="35">

                    <Label x:Name="btnLogout" HorizontalAlignment="Left" Margin="60,5,0,0" Content="Logout"  Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" MouseUp="btnLogout_MouseUp">

                    </Label>
                    <Image  Source="img\icons\logout.png" Height="20px" Width="20px"  Margin="25,0,0,0"/>
                </StackPanel>
            </StackPanel>
        </Expander>`
Harjeet Singh
  • 388
  • 2
  • 6
  • 22
  • The 'circular icon' is actually a WPF ToggleButton that toggles the visibility of the expander's content. So if you get rid of it, you will not be able to open and close the expander. Is your question that you want to *change* the appearance of the 'circular icon'? – Gayot Fow May 29 '14 at 19:25
  • Thanks @GayotFow yes i want to change the appearance of Toggle button. want to change ToggleButton icon as well if possible. – Harjeet Singh May 30 '14 at 03:46
  • 1
    Indeed this is possible, but you will need to change the control template. There is a lot of trial and error in that process if you haven't done it before. The icon itself is a WPF "Path" vector. I can show you where it is in the Xaml, but that's about all until you get very specific. – Gayot Fow May 30 '14 at 11:03
  • Does this answer your question? [how to change icon expander in wpf](https://stackoverflow.com/questions/11090524/how-to-change-icon-expander-in-wpf) – StayOnTarget Jul 08 '21 at 14:35

1 Answers1

0

Try to use that code:

<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400">
    <StackPanel>
        <StackPanel.Resources>

            <Style TargetType="Border" x:Key="RacePitBorderStyle" >
                <Style.Resources>
                    <LinearGradientBrush x:Key="BackBrush" StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Color="#EF3132" Offset="0.1" />
                        <GradientStop Color="#D62B2B" Offset="0.9" />
                    </LinearGradientBrush>
                </Style.Resources>
                <Setter Property="Background" Value="{StaticResource BackBrush}"/>
            </Style>

            <DataTemplate x:Key="titleText">
                <Border Style="{StaticResource RacePitBorderStyle}" Height="24">
                    <TextBlock Text="{Binding}" 
                        Margin="4 0"
                        VerticalAlignment="Center"
                        Foreground="White"
                        FontSize="11" 
                        FontWeight="Normal"
                        Width="{Binding
                        RelativeSource={RelativeSource
                        Mode=FindAncestor,
                        AncestorType={x:Type Expander}},
                        Path=ActualWidth}"
                        TextWrapping="Wrap"/>
                </Border>
            </DataTemplate>

            <Style TargetType="{x:Type Expander}">
                <Setter Property="HeaderTemplate" Value="{StaticResource titleText}"/>
            </Style>

        </StackPanel.Resources>

        <Expander Name="hcontCtrl" Header="This is the header.">
            <StackPanel>
                <TextBox>This is a textbox</TextBox>
                <Button>A button</Button>
            </StackPanel>
        </Expander>

    </StackPanel>
</Page>
MRebai
  • 5,344
  • 3
  • 33
  • 52
  • This code does not remove the round icon on the expander. Did you actually try it? Or better still, did you read the OP's question? – Gayot Fow May 29 '14 at 18:52