Hello community members!
In my solution I am using the xamtilemanager to administrate certain files. To delete or copy an item of the tiles i would like to bind the current selected item to my viewModel. If an Item is selected I want to execute delete or copy commands.
Unfortunatley I have not found a SelectedItem/SelectedValue or ActiveItem Property as it could be found eg in the xamdatagrid. Browsing the forum resources i found the following thread http://es.infragistics.com/community/forums/t/96889.aspx which uses an EventSetter for the PreviewMouseLeftButtonUp Event. Is this the only way to find out which tile was selected?Thank you for the information
Hello Andreas,
I have modified the sample project that I had originally sent you to remove the hook into the XamTile.MouseLeftButtonUp event in the CustomTileManager.Loaded event in favor of a Style for XamTile that uses an EventSetter for the MouseLeftButtonUp event. This ensures that the event will fire for each XamTile that exists within this derivation of the XamTileManager, and eliminates the need for the timer that you are currently using.
In the event handler for the XamTile.MouseLeftButtonUp event invoked by this event setter, I would simply recommend that you cast the sender to a XamTile, and get the data item from the tile.Content property. Then, you can check if that data item is the "SelectedItem" of your custom tile manager. If it is, then set the tile manager's selected item to null. If it isn't, you can set the tile manager's selected item to that data item. The property changed callback for the custom selected item dependency property will handle the rest; on terms of styling the XamTile that represents the selected item.
I have attached the modified sample project to this post. I hope this helps you.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello grubarec,
I believe the issue you were seeing was being caused due to the virtualization of the tiles that were out of view. When you set the initial mouse event on the tiles when the XamTileManager loaded, you were setting them on each of the tiles, but those tiles get recreated or recycled when they scroll into view. This is why the mouse event wasn't working on all of the tiles after scrolling the XamTileManager.
It appears that your most recent sample project solves this issue, but you may see performance issues with this solution in the long run. Rather than hooking and unhooking the MouseLeftButtonUp event on a timer, you may want to use a Style for XamTile that hooks into the MouseLeftButtonUp event via an EventSetter. This way, you can ensure that this event will fire for all tiles in your XamTileManager. You also may be able to use a trigger in this style and reference the SelectedItem property of your custom XamTileManager against the content of your XamTiles to place the "selected" background color on the tile.
I am currently working on a sample to demonstrate this to you, as I do believe there is a better way to achieve this requirement than what is currently being used.
Hello Again!
Attached please find the sample solution
Hello Andrew!
After some test, I found that I could add the TileStateChanging event to set the missing item selections.
If the NewState Property of the TileStateChangingEventArgs is set to TileState.Normal, I start a timer. The timer event than adds the eventhandlers for the separate tiles. I added the timer, as in the TileStateChanging Event, not all tiles are set.
Sorry, that I had to remove the Reply tag, but I have found some issues about the selection mode.
Attached please find the modified sample in which I load 100 elements (numbers only, no names as this should be enough for the sample) into the tilemanager and I made the template a little bit bigger.
After the start I see the first 26 elements.
1) If the scroll bar is moved to the right, I can click on any tile, but the selectedItem is not called. I think this is an issue of the virtualization. So I tried
<ig:NormalModeSettings ShowAllTiles="true" />
When this option is set, all tiles are displayed and could be selected. However, the compression is no option for me.2) When any tile is maximized, the other tiles are loaded into the right next to the tileSplitter. The first items in the list could be still selected, but scrolling down the list, the other tiles are no longer selectable. 3) After I minimized the current maximized window, other tiles are still not selectable.
I have already added handlers for mouse, touch and stylus "enter" and "move" events to enable the selection mode again. This maked the screen flickr when the mouse enters the tilemanager area. Which handlers do I have to add for the Tile maximization and minimization so that the selection is enabled again?As I said already, the ShowAllTiles="true" property is no option for me, how can i still set the selection mode for all tiles if the virtualization is enabled?Are there any events if the scrollbar is moved in one direction so that I can add methods to those events where I set the selection mode?
Thank you for you help