static bool isbool = false;
private void BindGameDelete()
{
Tile tile = new Tile();
List<Color> list = new List<Color>();
list.Add(Colors.Blue);
list.Add(Colors.Brown);
if (isbool)
{
tile.Background = new SolidColorBrush(list[0]);
isbool = false;
}
else
{
tile.Background = new SolidColorBrush(list[1]);
isbool = true;
}
tile.Width = 456;
tile.Height = 60;
ContextMenu cm = new ContextMenu();
cm.IsZoomEnabled = false;
RoutedEventHandler clickHandler = new RoutedEventHandler(GameDelete_Click);
// Add "edit" entry
MenuItem menuItem = new MenuItem()
{
Header = "取消关注",
Tag = "Delete"
};
menuItem.Click += clickHandler;
cm.Items.Add(menuItem);
ContextMenuService.SetContextMenu(tile, cm);
addTile.Children.Add(tile);
}
private void GameDelete_Click(object sender, RoutedEventArgs e)
{
var gameToDelte = ((MenuItem)sender).CommandParameter;
}
private void Tile_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
BindGameDelete();
}
<StackPanel x:Name="addTile" Grid.Row="1" Orientation="Vertical">
<c4f:Tile Background="Red" Content="11111" Width="456" Height="60" Hold="Tile_Hold"/>
<!--<c4f:Tile Background="Gray" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Green" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Yellow" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Violet" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Tomato" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="YellowGreen" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Thistle" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Turquoise" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Tomato" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Teal" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="Tan" Content="11111" Width="456" Height="60"/>
<c4f:Tile Background="SteelBlue" Content="11111" Width="456" Height="60"/>-->
</StackPanel>