I've been using the RadTileList for a while and I've not noticed this behaviour with the previous releases (thought I may have just not noticed). However I'm really struggling to deselect a tile after a user clicks on it.
In my main app when a user selects a tile it normally triggers a change to the viewmodel and another view is presented. When I then go back to the main view no tiles are selected, which is as desired.
But I have a tile that triggers a background process, spawns another window and makes the tile disabled. It still show selected though. When the process finishes the tile is enabled again, but it's still selected. The enable/disable is done by a viewmodel binding, so it's all automatic.
In my app I've just been setting the SelectedItem to null and it's appeared to behave how I want. I've just created a brand new project and tried to get the deselection working in isolation and I just cannot get it to deselect.
This is the WPF:
<
telerik:RadTileList
HorizontalAlignment
=
"Left"
Margin
=
"105,113,0,0"
VerticalAlignment
=
"Top"
SelectionChanged
=
"RadTileList_SelectionChanged"
>
<
telerik:Tile
x:Name
=
"TileA"
Background
=
"#FFC71D1D"
>
<
TextBlock
Text
=
"Tile A"
/>
</
telerik:Tile
>
<
telerik:Tile
x:Name
=
"TileB"
Background
=
"#FF3FB812"
>
<
TextBlock
Text
=
"Tile B"
/>
</
telerik:Tile
>
<
telerik:Tile
x:Name
=
"TileC"
Background
=
"#FF2439BF"
>
<
TextBlock
Text
=
"Tile C"
/>
</
telerik:Tile
>
</
telerik:RadTileList
>
This is the code in the .cs file:
private
void
RadTileList_SelectionChanged(
object
sender, SelectionChangedEventArgs e)
{
if
(e.AddedItems.Count > 0)
{
var theTiles = sender
as
RadTileList;
if
(theTiles.SelectedItem == TileA)
{
//do some stuff here
}
if
(theTiles.SelectedItem == TileB)
{
//do some stuff here
}
theTiles.SelectedItem =
null
;
}
}
In my app the tile just doesn't get deselected, but in this demo I end up in an infinite loop, where the SelectionChanged event is constantly triggered.
I figure I must be doing something pretty wrong for this not to work.
Any clues? or indeed how I should automatically deselect the item?
BTW: I've looked at removing the styling for the selection, but it is still actually selected so the user has to click several times for it to silently deselect then select again, which isn't desirable.