Skip to content

Commit 70495fe

Browse files
committed
Implementing ShowMeTheXAML
1 parent 56fee88 commit 70495fe

37 files changed

+2537
-2036
lines changed

MainDemo.Wpf/App.xaml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<Application x:Class="MaterialDesignColors.WpfExample.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:showMeTheXaml="clr-namespace:ShowMeTheXAML;assembly=ShowMeTheXAML"
5+
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
6+
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
7+
xmlns:smtxAe="clr-namespace:ShowMeTheXAML.AvalonEdit;assembly=ShowMeTheXAML.AvalonEdit"
8+
xmlns:system="clr-namespace:System;assembly=mscorlib"
9+
xmlns:materialDesignDemo="clr-namespace:MaterialDesignDemo"
410
StartupUri="MainWindow.xaml">
511
<Application.Resources>
612
<ResourceDictionary>
@@ -10,8 +16,83 @@
1016
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
1117
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
1218
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
13-
19+
<ResourceDictionary Source="pack://application:,,,/ShowMeTheXAML.AvalonEdit;component/Themes/xamldisplayer.xaml" />
1420
</ResourceDictionary.MergedDictionaries>
21+
22+
<Style TargetType="showMeTheXaml:XamlDisplay" BasedOn="{StaticResource {x:Type showMeTheXaml:XamlDisplay}}">
23+
<Style.Resources>
24+
<ResourceDictionary>
25+
<ResourceDictionary.MergedDictionaries>
26+
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ToggleButton.xaml" />
27+
</ResourceDictionary.MergedDictionaries>
28+
29+
<smtxAe:TextDocumentValueConverter x:Key="TextDocumentValueConverter"/>
30+
</ResourceDictionary>
31+
</Style.Resources>
32+
<Setter Property="VerticalContentAlignment" Value="Bottom" />
33+
<Setter Property="HorizontalContentAlignment" Value="Right" />
34+
<Setter Property="materialDesignDemo:XamlDisplayEx.ButtonDock" Value="Right" />
35+
<Setter Property="Formatter">
36+
<Setter.Value>
37+
<showMeTheXaml:XamlFormatter NewLineOnAttributes="True" Indent=" ">
38+
<showMeTheXaml:XamlFormatter.NamespacesToRemove>
39+
<system:String>http://materialdesigninxaml.net/winfx/xaml/themes</system:String>
40+
</showMeTheXaml:XamlFormatter.NamespacesToRemove>
41+
</showMeTheXaml:XamlFormatter>
42+
</Setter.Value>
43+
</Setter>
44+
<Setter Property="Template">
45+
<Setter.Value>
46+
<ControlTemplate TargetType="showMeTheXaml:XamlDisplay">
47+
<DockPanel>
48+
<materialDesign:PopupBox DockPanel.Dock="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(materialDesignDemo:XamlDisplayEx.ButtonDock)}"
49+
Padding="10" StaysOpen="True" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
50+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
51+
x:Name="PopupBox">
52+
<materialDesign:PopupBox.ToggleContent>
53+
<materialDesign:PackIcon Kind="Xaml" Cursor="Hand" ToolTip="View XAML"
54+
Foreground="{DynamicResource PrimaryHueDarkBrush}"
55+
Background="Transparent"
56+
Margin="3">
57+
<materialDesign:PackIcon.Style>
58+
<Style TargetType="materialDesign:PackIcon" BasedOn="{StaticResource {x:Type materialDesign:PackIcon}}">
59+
<Setter Property="Opacity" Value="0.2" />
60+
<Style.Triggers>
61+
<Trigger Property="IsMouseOver" Value="True">
62+
<Setter Property="Opacity" Value="1" />
63+
</Trigger>
64+
</Style.Triggers>
65+
</Style>
66+
</materialDesign:PackIcon.Style>
67+
</materialDesign:PackIcon>
68+
</materialDesign:PopupBox.ToggleContent>
69+
<Border MaxHeight="600" MaxWidth="800">
70+
<avalonEdit:TextEditor Document="{Binding Xaml, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TextDocumentValueConverter}}"
71+
Style="{StaticResource AvalonTextEditorXamlDisplay}" />
72+
</Border>
73+
</materialDesign:PopupBox>
74+
<Grid>
75+
<AdornerDecorator>
76+
<Border BorderBrush="{DynamicResource SecondaryAccentBrush}" Opacity=".4" Margin="-5">
77+
<Border.Style>
78+
<Style TargetType="Border">
79+
<Setter Property="BorderThickness" Value="0" />
80+
<Style.Triggers>
81+
<DataTrigger Binding="{Binding ElementName=PopupBox, Path=IsPopupOpen}" Value="True">
82+
<Setter Property="BorderThickness" Value="5" />
83+
</DataTrigger>
84+
</Style.Triggers>
85+
</Style>
86+
</Border.Style>
87+
</Border>
88+
</AdornerDecorator>
89+
<ContentPresenter />
90+
</Grid>
91+
</DockPanel>
92+
</ControlTemplate>
93+
</Setter.Value>
94+
</Setter>
95+
</Style>
1596
</ResourceDictionary>
1697
</Application.Resources>
1798
</Application>

MainDemo.Wpf/App.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using System.Windows;
1010
using System.Windows.Markup;
11+
using ShowMeTheXAML;
1112

1213
namespace MaterialDesignColors.WpfExample
1314
{
@@ -18,6 +19,7 @@ public partial class App : Application
1819
{
1920
protected override void OnStartup(StartupEventArgs e)
2021
{
22+
XamlDisplay.Init();
2123
//Illustration of setting culture info fully in WPF:
2224
/*
2325
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

0 commit comments

Comments
 (0)