I have a style defined for XamTile as follows:
<Style TargetType="ig:XamTile" x:Key="fistyle"> <Setter Property="IsMaximized" Value="{Binding Selected,Mode=TwoWay}"/> </Style>Within the XamTileManager this style is being set as the ItemContainerStyle. The theory is that as I add new items to the TileManager I can set Selected=true on the items viewmodel to make the new tile Maximzed.
Unfortunately, it doesn't work. There are no binding errors and I have confirmed the Style is applied. (I set IsHitTestVisible=False in the style to test it).
Hello,
I am attaching a sample of one way of implementing it.
When you load the sample you will see the second tile maximized. This is initially set up in XAML. Then use the "Add Tile" button to add new tiles. The new tiles are set up using the style like the one you provided, which sets the new tile in maximized state.
Let me know how this works for you, or any questions you may have.
Sam
Hi Sam,
I have looked at the sample. It is working fine. Now my question is:
Just to clarify the context, In my case, I use a command to handle the button click. The command is in the view model. So I do not want to access view's content (tile) at view model. I have a IsMaximized property in the view model. All we need to bind the IsMaximided property of the tile to the view model 's property. It is best for me if I can do the binding in XAML.
Thanks,
Amatul
Hi Amatul,
I used the Style as one way of applying the Setter with IsMaximized property. It was not intended for the Tile's appearance. Sure you can use the ItemContainerStyle for that matter, and it's not limitted to be done in code behind either. It can be done in XAML.
As far as binding the Tile's IsMaximized property to your view model's IsMaximized property, you can do it in XAML, but keep in mind that any changes to your view model's property won't be propegated to the binding unless your object implements INotifyPropertyChanged interface.
IsMaximized="{Binding Path=isMaximized}
Thanks a lot for such a quick reply. Yes, my object implements INotifyPropertyChanged interface.
I tried to change the sample you provided to use ItemContainerStyle to set IsMaximized. But it is not working. I have attached the modified version here. Could you please tell me what is wrong there? Also, It will be great if you provide a working version.
My statement about using the ItemContainerStyle may have mislead you. I meant that you could use ItemContainerStyle for Tile appearance, not for maximizing the tile, because ItemContainerStyle applies to all tiles and you cannot set all tiles maximized. For initial load you can bind the Tile's IsMaximized proprty to your view model, and when you add new tile, since that is implemented is in code you need to reference the IsMaximized setter in code. You mentioned that you were using button command adding new tiles, and that's done in code I assume, and if the new tile needs to be maximized at that time, then you need to reference the IsMaximized setter in code.
If you can show me, possibly with code, how exactly you are adding new tiles, I will see what else we can do in XAML if possible.