I have this SfAccordion:
<Layout:SfAccordion Grid.Row="1" SelectedIndex="0" AccentBrush="{StaticResource BrandBrush}"
SelectionMode="ZeroOrOne" Width="395" SelectionChanged="SfAccordion_SelectionChanged" >
<Layout:SfAccordion.HeaderTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90" />
<ColumnDefinition />
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<StackPanel Background="#b3d6ef" Grid.Column="0" Width="40" Height="40" Orientation="Vertical" Margin="0,10,0,0">
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="2" FontFamily="Segoe UI Semilight" FontSize="30" FontWeight="SemiLight" TextAlignment="Center"></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1">
<TextBlock Margin="0,10,0,0" Text="{Binding}" FontFamily="Segoe UI Semilight" FontSize="24" FontWeight="SemiLight" Foreground="#ffffff" VerticalAlignment="Center" HorizontalAlignment="Left"/>
</StackPanel>
<Grid Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Center">
<Rectangle x:Name="AcItemRectangle" Width="28" Height="28" Fill="#aa6861" Stroke="#aa6861" Visibility="Visible"></Rectangle>
<Polygon x:Name="AcItemTriangle" Points="0,0 28,0, 14,35" Stroke="#aa6861" Fill="#aa6861" Visibility="Collapsed" />
<TextBlock Text="1" Foreground="White" FontFamily="Segoe UI Semilight" FontSize="24" FontWeight="SemiLight" HorizontalAlignment="Center" Margin="-2,0,0,0" />
</Grid>
</Grid>
</DataTemplate>
</Layout:SfAccordion.HeaderTemplate>
<Layout:SfAccordionItem Width="420" LostFocus="SfAccordionItem_LostFocus" BorderBrush="Transparent" Margin="0,10,0,0" Header="Meeting introduction" FontFamily="Segoe UI Semilight" FontSize="24" FontWeight="SemiLight" Foreground="#ffffff">
<Grid Height="212" Background="{StaticResource BrandBrush}">
</Grid>
</Layout:SfAccordionItem>
<Layout:SfAccordionItem Width="420" BorderBrush="Transparent" Margin="0,0" Header="Meeting introduction" FontFamily="Segoe UI Semilight" FontSize="24" FontWeight="SemiLight" Foreground="#ffffff" Selected="SfAccordionItem_Selected" LostFocus="SfAccordionItem_LostFocus">
<Grid Height="212" Background="{StaticResource BrandBrush}">
</Grid>
</Layout:SfAccordionItem>
<Layout:SfAccordionItem Width="420" LostFocus="SfAccordionItem_LostFocus" BorderBrush="Transparent" Margin="0" Header="Meeting introduction" FontFamily="Segoe UI Semilight" FontSize="24" FontWeight="SemiLight" Foreground="#ffffff">
<Grid Height="212" Background="{StaticResource BrandBrush}">
</Grid>
</Layout:SfAccordionItem>
</Layout:SfAccordion>
Im trying to change the visibility property of the Rectangle and Polygon in the DataTemplate
I tried with something like this but when the selection changes, the last item keeps the properties of the Polygon and Rectangle, only when i select another they change
private void SfAccordion_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var accord = sender as SfAccordion;
foreach (SfAccordionItem data in accord.Items)
{
var x = FindChildControl<Rectangle>(data, "AcItemRectangle") as Rectangle;
x.Visibility = Visibility.Visible;
var x2 = FindChildControl<Polygon>(data, "AcItemTriangle") as Polygon;
x2.Visibility = Visibility.Collapsed;
}
foreach (SfAccordionItem data in accord.Items)
{
if(data.IsSelected)
{
var x = FindChildControl<Rectangle>(data, "AcItemRectangle") as Rectangle;
x.Visibility = Visibility.Collapsed;
var x2 = FindChildControl<Polygon>(data, "AcItemTriangle") as Polygon;
x2.Visibility = Visibility.Visible;
}
}
}
the objective is something like this