Hi,
I'm learning WPF. I'm using MahApps plugin to design my GUI.
I want to use the tiles panel to generate a tile for each plugin in the list but I have an issue with the binding. The issue is the tiles "HELLO" and "HELLO2" are not displayed, I can see only 1 tile without a text
What I have tried:
MainView.xaml
<Grid>
<Controls:MetroAnimatedTabControl x:Name="metroAnimatedTabControl" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ClipToBounds="False" >
<TabItem Header="" FontFamily="Segoe MDL2 Assets" ToolTip="DashBoard">
<WrapPanel Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"DataContext="{Binding Plugins}">
<Controls:Tile Title="{Binding Name}" removed="Navy" IsEnabled="True" FontFamily="Calibri">
</Controls:Tile>
</WrapPanel>
</TabItem>
....
MainView.cs
private List<Plugin> plugins_;
...
public MainWindow()
{
plugins_ = new List<Plugin>();
Plugin toto = new Plugin();
toto.Name = "HELLO";
plugins_.Add(toto);
Plugin toto2 = new Plugin();
toto2.Name = "HELLO2";
plugins_.Add(toto2);
InitializeComponent();
...
}
...
public List<Plugin> Plugins
{
get { return plugins_; }
}
Plugin.cs
public class Plugin
{
private String name_;
public string Name
{
get { return name_; }
set { name_ = value; }
}
}
Following RickZeeland sample, I wrote this but same result :
<Grid>
<Controls:MetroAnimatedTabControl x:Name="metroAnimatedTabControl" Margin="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ClipToBounds="False" >
<TabItem Header="" FontFamily="Segoe MDL2 Assets" ToolTip="DashBoard">
<ItemsControl x:Name="pluginsControl" Margin="10">
<ItemsControl.Template>
<ControlTemplate>
<WrapPanel Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Controls:Tile Title="{Binding Path=Name, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:Plugin}}" removed="Navy" IsEnabled="True" FontFamily="Calibri">
<Grid>
<Image Width="64" Height="64" RenderOptions.BitmapScalingMode="HighQuality"
Source="http://ezcomponents.org/images/logos/icon-64x64.png"></Image>
</Grid>
</Controls:Tile>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
...
</Controls:MetroAnimatedTabControl>
</Grid>