fixed a bug of demo

This commit is contained in:
NaBian committed 2020-04-10 00:47:31 +08:00
1 parent 8c7f34ad4a
commit add2fd8237
6 files changed
+106 -6

No files matched your search

@@ -17,13 +17,13 @@
<Border Style="{StaticResource BorderClip}" Margin="32,32,0,32" CornerRadius="10,0,0,10" Background="{DynamicResource RegionBrush}" Width="800">
<TabControl Grid.Row="1" Style="{StaticResource TabControlInLine}">
<TabItem Header="XAML">
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="XML" Name="EditorXaml" Margin="4" ShowLineNumbers="True"/>
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="XML" Name="EditorXaml"/>
</TabItem>
<TabItem Header="C#">
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorCs" Margin="4" ShowLineNumbers="True"/>
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="C#" Name="EditorCs"/>
</TabItem>
<TabItem Header="VM">
<avalonedit:TextEditor IsReadOnly="True" FontFamily="Consolas" Background="{DynamicResource RegionBrush}" SyntaxHighlighting="C#" Name="EditorVm" Margin="4" ShowLineNumbers="True"/>
<avalonedit:TextEditor Style="{StaticResource TextEditorCustom}" SyntaxHighlighting="C#" Name="EditorVm"/>
</TabItem>
</TabControl>
</Border>
@@ -56,10 +56,13 @@ namespace HandyControlDemo.UserControl
if (ViewModelLocator.Instance.Main.SubContent is FrameworkElement demoCtl)
{
var xamlPath = $"UserControl/{typeKey}/{demoCtl.GetType().Name}.xaml";
var demoCtlTypeName = demoCtl.GetType().Name;
var xamlPath = $"UserControl/{typeKey}/{demoCtlTypeName}.xaml";
var dc = demoCtl.DataContext;
var dcTypeName = dc.GetType().Name;
var vmPath = $"ViewModel/{dcTypeName}";
var vmPath = !Equals(dcTypeName, demoCtlTypeName)
? $"ViewModel/{dcTypeName}"
: xamlPath;
EditorXaml.Text = DemoHelper.GetCode(xamlPath);
EditorCs.Text = DemoHelper.GetCode($"{xamlPath}.cs");