我有一个名为MizahPanoramaItems
的类,一个名为PanoramaKarikaturItems
的列表和一个名为MizahViewModel
的ViewModel。我的问题是我的列表框'datatemplate的事件不起作用。
<Grid x:Name="LayoutRoot" Background="White">
<phone:Panorama SelectionChanged="panaromaMain_SelectionChanged"
x:Name="panaromaMain" Title="mizah"
Style="{StaticResource PanoramaStyle}"
Background="#FFECF0F1" Foreground="#FF040202">
<phone:Panorama.TitleTemplate>
<DataTemplate>
<!--<TextBlock Text="{Binding}" FontSize="100" Margin="0,20,0,0"></TextBlock>-->
</DataTemplate>
</phone:Panorama.TitleTemplate>
<phone:PanoramaItem x:Name="panoramaKarikatur" Header="karikatür" Orientation="Horizontal" Foreground="#A6CC33">
<ListBox Margin="0,0,0,10" ItemsSource="{Binding PanoramaKarikaturItems}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<MetroEventToCommand:EventToCommandManager.Collection>
<MetroEventToCommand:EventToCommand Command="{Binding PanoramaTypeSelection}" Event="Tap"/>
</MetroEventToCommand:EventToCommandManager.Collection>
<c4f:Tile Width="410" Height="200" Margin="0,12,0,0" Background="{Binding ElementName=panoramaKarikatur,Path=Foreground}" Label="{Binding Name}" Foreground="White">
<Grid>
<c4f:TileNotification Background="White" Content="{Binding Count}" Foreground="{Binding ElementName=panoramaKarikatur,Path=Foreground}"/>
<Image Source="{Binding ImagePath,Converter={StaticResource UriToImage}}" Stretch="None" Width="140" Height="150" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Grid>
</c4f:Tile>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</phone:PanoramaItem>.....
这是我在ViewModel中的列表;
private List<MizahPanoramaItems> panoramaKarikaturItems;
public List<MizahPanoramaItems> PanoramaKarikaturItems
{
get { return panoramaKarikaturItems; }
set { SetProperty<List<MizahPanoramaItems>>(ref panoramaKarikaturItems, value, "PanoramaKarikaturItems"); }
}
这是我的MizahPanoramaItems类
public class MizahPanoramaItems:NotifyPropertyChanged
{
public MizahPanoramaItems()
{
PanoramaTypeSelection = new DelegateCommand(PanoramatypeSelectionAction);
}
public enum Types
{
Caps,
Karikatur,
DiziFilm
}
private int _count;
public int Count
{
get { return _count; }
set { SetProperty<int>(ref _count, value, "Count"); }
}
private Types _type;
public Types Type
{
get { return _type; }
set { SetProperty<Types>(ref _type, value, "Type"); }
}
private string _path;
public string Path
{
get { return _path; }
set { SetProperty<string>(ref _path, value, "Path"); }
}
private string _pathName;
public string PathName
{
get { return _pathName; }
set { SetProperty<string>(ref _pathName, value, "PathName"); }
}
private string _imagePath;
public string ImagePath
{
get { return _imagePath; }
set { SetProperty<string>(ref _imagePath, value, "ImagePath"); }
}
private string _name;
public string Name
{
get { return _name; }
set { SetProperty<string>(ref _name, value, "Name"); }
}
public ICommand PanoramaTypeSelection { get; set; }
public void PanoramatypeSelectionAction()
{
}
}
和我的命令实现;
public ICommand PanoramaTypeSelection { get; set; }
public void PanoramatypeSelectionAction()
{
//it is not working
}
public MizahPanoramaItems()
{
PanoramaTypeSelection = new DelegateCommand(PanoramatypeSelectionAction);
}