Skip to content

Instantly share code, notes, and snippets.

@habibg1232191
Created May 21, 2021 17:06
Show Gist options
  • Save habibg1232191/4ffa66b5346819fe3a5df6c37774a2b0 to your computer and use it in GitHub Desktop.
Save habibg1232191/4ffa66b5346819fe3a5df6c37774a2b0 to your computer and use it in GitHub Desktop.
<controls:MList Items="{Binding Photos}">
<controls:MList.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding urls}"></TextBlock>
</Grid>
</DataTemplate>
</controls:MList.ItemTemplate>
</controls:MList>
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Switch_Wallparer.Views.Controls">
<Design.PreviewWith>
<controls:MList />
</Design.PreviewWith>
<Style Selector="controls|MList">
<!-- Set Defaults -->
<Setter Property="Template">
<ControlTemplate>
<Grid></Grid>
</ControlTemplate>
</Setter>
</Style>
</Styles>
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
namespace Switch_Wallparer.Views.Controls
{
public class MList : ListBox
{
public MList()
{
AddHandler(PointerPressedEvent, (_, _) =>
{
Console.WriteLine("Pressed");
foreach (var item in DataTemplates)
{
Console.WriteLine(item);
}
}, RoutingStrategies.Tunnel);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment