Skip to content

Commit d5d7314

Browse files
authored
Merge pull request #4 from wongjiahau/smtx-copy-button
Added copy button for XamlDisplay
2 parents 601c2c0 + 625af5e commit d5d7314

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

MainDemo.Wpf/App.xaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,21 @@
6666
</materialDesign:PackIcon.Style>
6767
</materialDesign:PackIcon>
6868
</materialDesign:PopupBox.ToggleContent>
69-
<Border MaxHeight="600" MaxWidth="800">
70-
<avalonEdit:TextEditor Document="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TextDocumentValueConverter}}"
69+
<StackPanel>
70+
<Border MaxHeight="600" MaxWidth="800">
71+
<avalonEdit:TextEditor Document="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TextDocumentValueConverter}}"
7172
Style="{StaticResource AvalonTextEditorXamlDisplay}" />
72-
</Border>
73+
</Border>
74+
<Button
75+
Margin="0 10 0 0"
76+
Tag="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}}"
77+
Click="CopyButton_onClick"
78+
HorizontalAlignment="Right"
79+
Style="{StaticResource MaterialDesignRaisedButton}"
80+
>
81+
COPY
82+
</Button>
83+
</StackPanel>
7384
</materialDesign:PopupBox>
7485
<Grid>
7586
<AdornerDecorator>
@@ -96,3 +107,4 @@
96107
</ResourceDictionary>
97108
</Application.Resources>
98109
</Application>
110+

MainDemo.Wpf/App.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Threading;
88
using System.Threading.Tasks;
99
using System.Windows;
10+
using System.Windows.Controls;
1011
using System.Windows.Markup;
1112
using ShowMeTheXAML;
1213

@@ -30,5 +31,10 @@ protected override void OnStartup(StartupEventArgs e)
3031

3132
base.OnStartup(e);
3233
}
34+
35+
private void CopyButton_onClick(object sender, RoutedEventArgs e) {
36+
var toBeCopied = ((Button)sender).Tag.ToString();
37+
Clipboard.SetDataObject(toBeCopied);
38+
}
3339
}
3440
}

0 commit comments

Comments
 (0)