Hello,
I like to use the Tile Manager without the headers, with this Forum help i found out how. But now the question,how can I miximize a current Tile via Code. I can only found a reference of a tile if I have a Item, but when i click of a button inside the Tile i found now "actualTile" or "currentNode" or whatever.
For example: this work for the fix first Item, but I search the current...
private void _tm_MouseDoubleClick(object sender, MouseButtonEventArgs e) { XamTile tileToMaximize = this._tm.TileFromItem(this._tm.Items[0]); tileToMaximize.IsMaximized = true;
}
Thanks for help, and greetings from germany
Thomas
Hello Thomas,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the Click event of the Button I put inside the XamTile and set its Parent’s (which is the XamTile) IsMaximized Property to True. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hello Stefan,
thanks for you support, i think i have as beginner some easy wpf problems :(But in my application i use datatemplates and then the parent of the Button is Null.
Hmmmm, can you help a beginner....
Here a little example where the parent is null, i hope you understand.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:ig="http://schemas.infragistics.com/xaml"> <Window.Resources> <DataTemplate x:Key="LargeTileView"> <Button Name="myTestButton" Content="{Binding Source}" Click="Button_Click"/> </DataTemplate> </Window.Resources> <Grid> <ig:XamTileManager Name="xamTileManager1" ItemTemplate="{StaticResource LargeTileView}" ItemsSource="{x:Static Fonts.SystemFontFamilies}"> </ig:XamTileManager> </Grid></Window>
---- code behind
private void Button_Click(object sender, RoutedEventArgs e) { ((sender as Button).Parent as XamTile).IsMaximized = true; }
Since you use ItemsSource I can suggest you change the Button’s Click event handler like this:
(((sender as Button).TemplatedParent as ContentPresenter).TemplatedParent as XamTile).IsMaximized = true;
Please let me know if this helps you or you need further assistance on this matter.
I can suggest you set the ContentTemplate Property of the ContentPresenter, which is in the XamTile's Template, to {TemplateBinding ContentTemplateResolved}. This way the ItemTempalteMaximized and ItemTemplateMinimizedExpanded Properies will work correctly.
Hope this helps you.
your solution doesn't work. Only the content will maximized. But it is the wrong content. The content should change to TemplateMaximized.The button should be replaced with a Text "MytextBlock Maximized"
Thx for help
I have been looking into your code and I can suggest you replace the StackPanel used in the XamTile's Style Tempalte with Grid.
based on the previous problem a new problem is added.In the sample Code I remove the header and build templates for the maximzed and minimizedExpanded view.if I used the tilemanager with normal header everythinbgs works fine, but when i remove the header then the view will maximized but there content is always the same, it doesn't change to the template. Where is the Problem ? I think the style for xamTile WithoutHeader remove the contents or fixed it to the normal view.
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igPrim="http://schemas.infragistics.com/xaml/primitives" Title="MainWindow" Height="350" Width="525" xmlns:ig="http://schemas.infragistics.com/xaml"> <Window.Resources> <!-- TILE MANAGER--> <!-- style for TileHeaderPresenter will use in the style for xamTile (found in infragistic forum)--> <Style x:Key="tileHeaderStyle" TargetType="igPrim:TileHeaderPresenter"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igPrim:TileHeaderPresenter"> <Grid Background="Transparent"> <ContentPresenter /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- style for xamTile that will apply on all tiles (found in infragistic forum)--> <Style TargetType="ig:XamTile" x:Key="WithoutHeader"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ig:XamTile"> <StackPanel> <igPrim:TileHeaderPresenter x:Name="TileHeader" AutomationProperties.AutomationId="TileHeader" Style="{StaticResource tileHeaderStyle}"> <ContentPresenter Visibility="{TemplateBinding ContentVisibility}"/> </igPrim:TileHeaderPresenter> <Rectangle x:Name="Overlay"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> <DataTemplate x:Key="TemplateMaximized"> <Grid> <TextBlock>MytextBlock Maximized</TextBlock> </Grid> </DataTemplate> <DataTemplate x:Key="TemplateMinimized"> <Grid> <TextBlock>MytextBlock Minimized</TextBlock> </Grid> </DataTemplate> <DataTemplate x:Key="LargeTileView"> <Button Name="myTestButton" Content="{Binding Source}" Click="Button_Click"/> </DataTemplate> </Window.Resources> <Grid> <ig:XamTileManager Name="xamTileManager1" ItemTemplate="{StaticResource LargeTileView}" ItemsSource="{x:Static Fonts.SystemFontFamilies}" ItemTemplateMaximized ="{StaticResource TemplateMaximized}" ItemTemplateMinimizedExpanded="{StaticResource TemplateMinimized}" ItemContainerStyle="{StaticResource WithoutHeader}" > <!-- Remove the last line with the ItemContainerStyle for the normal view with header--> </ig:XamTileManager> </Grid></Window>
--Code Behind private void Button_Click(object sender, RoutedEventArgs e) { ((((sender as Button).TemplatedParent) as ContentPresenter).TemplatedParent as XamTile).IsMaximized = true; }
By the way, is it possible to change the itemcontainerstyle from one view to another? I think no, without reload the items the tiles can't change the header view.I'd prefer the first view without the header and after maximized the view with header. Any idea.
greetings
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.