hey there i am having problem i have
List<List<memoryCard>>
that i want to show in my xmal in a button how can I bind my button to the data i want thos is my usercontrol :
<
<ControlTemplate x:Key="ButtonControlTemplate1" TargetType="{x:Type Button}">
<Grid>
<!--i think this is the place where i make mistake :-->
<TextBlock Text="{Binding Path=CardWasfounded}"/>
<Rectangle Margin="4,5,8,2" Stroke="Black" RadiusX="45" RadiusY="45" StrokeThickness="3"/>
</Grid>
</ControlTemplate>
<DataTemplate x:Key="DataTemplate_Level2">
<Button Content="{Binding}" Height="40" Width="50" Margin="4,4,4,4" Template="{DynamicResource ButtonControlTemplate1}"/>
</DataTemplate>
<DataTemplate x:Key="DataTemplate_Level1">
<ItemsControl ItemsSource="{Binding }" ItemTemplate="{DynamicResource DataTemplate_Level2}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</DataTemplate>
I want every button to have binding to this memory card
class memoryCard : INotifyPropertyChanged
{
#region c'tor
public memoryCard(Brush _buttonColor)
{
buttonColor=_buttonColor;
}
#endregion
#region allReadyFoundedCard
bool cardWasfounded = false;
public bool CardWasfounded
{
get
{
return cardWasfounded;
}
set
{
if (cardWasfounded != value)
{
cardWasfounded = value;
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs("cardWasfounded"));
}
}
}
}
#endregion
#region colorofbutton
string name = "sdasdas";
public Brush buttonColor;
public Brush ButtonColor
{
get
{
return buttonColor;
}
set
{
if (buttonColor != value)
{
buttonColor = value;
if (PropertyChanged != null) PropertyChanged(this,
new PropertyChangedEventArgs("buttonColor"));
}
}
}
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
#endregion
}
whom i want to bind to one of my grids this way :
using this mainwindow class:
public MainWindow()
{
List<List<memoryCard>> lsts = new List<List<memoryCard>>();
for (int i = 0; i < 5; i++)
{
lsts.Add(new List<memoryCard>());
for (int j = 0; j < 5; j++)
{
lsts[i].Add(new memoryCard(Brushes.Green));
}
}
InitializeComponent();
lst.ItemsSource = lsts;
}