-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml
80 lines (80 loc) · 3.84 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<Window x:Class="WPFWebView2TabControl.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFWebView2TabControl"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="TabBrowserDataTemplate"
DataType="{x:Type local:BrowserTabItemViewModel}">
<Grid>
<local:BrowserTabItemUC />
</Grid>
</DataTemplate>
<DataTemplate x:Key="TabBrowserHeaderDataTemplate">
<Grid>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}"
TextTrimming="CharacterEllipsis"
MaxWidth="140"
VerticalAlignment="Center" />
<Border BorderThickness="4" />
<Button x:Name="CloseTabButton"
Content="X"
Padding="0,-3,0,0"
Background="Transparent"
Command="{Binding DataContext.TabCloseCommand,
RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}"
CommandParameter="{Binding}"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Height="14"
Width="14" />
</StackPanel>
<Grid.ToolTip>
<ToolTip Placement="Top">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Title}"
MaxWidth="300"
TextWrapping="Wrap"
FontWeight="Black" />
<TextBlock Text="{Binding BaseURL}" />
</StackPanel>
</ToolTip>
</Grid.ToolTip>
</Grid>
<DataTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsMouseOver}"
Value="True" />
</MultiDataTrigger.Conditions>
<Setter TargetName="CloseTabButton"
Property="Opacity"
Value="1" />
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsMouseOver}"
Value="False" />
</MultiDataTrigger.Conditions>
<Setter TargetName="CloseTabButton"
Property="Opacity"
Value="0" />
</MultiDataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</Window.Resources>
<Grid>
<TabControl x:Name="BrowserTabControl"
SelectedIndex="{Binding BrowserTabControlSelectedIndex, Mode=TwoWay}"
ItemsSource="{Binding TabCollection}"
ItemTemplate="{StaticResource TabBrowserHeaderDataTemplate}"
ContentTemplate="{StaticResource TabBrowserDataTemplate}"/>
</Grid>
</Window>