Reputation: 73928
I have a ListBox which show several images, every image has two status SELECTED and UNSELECTED. Switching from one status to another makes the image change url - the IDEA is like a Radio Buttons
No action when a user click on a SELECTED image. When a user click another UNSELECTED that image will be SELECTED and the previosly one will go in UNSELECTED.
Now in my code in Floors_SelectionChanged I am able to handle this scenario, my problem is when the application start I need PRE-SELECT and image.
I would need to know:
How to make this PRE-SELECTION happen?
<DataTemplate x:Key="FloorsListboxDataTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" TextWrapping="Wrap"
Text="{Binding Description,
FallbackValue='Description'}">
</TextBlock>
<Image x:Name="FloorImage"
Grid.Row="1"
Source="{Binding ImageUrlCurrent}"/>
</Grid>
</DataTemplate>
<Custom:SurfaceListBox x:Name="FloorsSurfaceListBox"
SelectionChanged="Floors_SelectionChanged"
Loaded="FloorsSurfaceListBox_Loaded"
ItemTemplate="{DynamicResource FloorsListboxDataTemplate}">
Upvotes: 1
Views: 47
Reputation: 5163
SelectedIndex = 0
when your ListBox's Loaded
event is fired? IF you're using x:Name on ListBox, can you call listbx.SelectedIndex = 0 when your custom control's Loaded
event is fired?Upvotes: 3