Skip to content

Instantly share code, notes, and snippets.

@DamianSuess
Created December 4, 2023 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamianSuess/d4af84772720db73781dd9f35eb65fcd to your computer and use it in GitHub Desktop.
Save DamianSuess/d4af84772720db73781dd9f35eb65fcd to your computer and use it in GitHub Desktop.
<UserControl.Resources>
<!--<converter:BoolStringConverter x:Key="BooleanToStringConverter" TrueValue="Yes" FalseValue="No" />
<converter:InverseBoolConverter x:Key="InverseBoolConverter" />-->
<ResourceDictionary>
<DataTemplate x:Key="GridDeviceInfo" DataType="models:DeviceInfo">
<Panel Background="Transparent">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="DoubleTapped">
<ia:InvokeCommandAction Command="{Binding $parent[Grid].((vm:AccessViewModel)DataContext).CmdCopyText}" CommandParameter="Hello" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<Grid ColumnDefinitions="Auto,8,*" RowDefinitions="Auto,Auto">
<TextBlock Text="{Binding DeviceTypeName}" Grid.ColumnSpan="3" />
<TextBlock Text="{Binding Address}"
Grid.Row="1"
Grid.Column="0" />
<TextBlock Text="{Binding Id}"
Grid.Row="1"
Grid.Column="2" />
</Grid>
</Panel>
</DataTemplate>
public DelegateCommand<string> CmdCopyText => new(async (text) =>
{
if (string.IsNullOrEmpty(text) || Application.Current is null || Application.Current.Clipboard is null)
return;
await Application.Current.Clipboard.SetTextAsync(text);
_notifications.Show("Clipboard", "Contents copied to clipboard");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment