8 changed files with 182 additions and 81 deletions
@ -0,0 +1,42 @@ |
|||
<UserControl x:Class="齐越慧眼.UserControls.BrowerTabPanelControl" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:hc="https://handyorg.github.io/handycontrol" |
|||
xmlns:local="clr-namespace:齐越慧眼.UserControls" |
|||
mc:Ignorable="d" |
|||
d:DesignHeight="450" d:DesignWidth="800"> |
|||
|
|||
<UserControl.Resources> |
|||
<Style TargetType="RadioButton"> |
|||
<Setter Property="Cursor" Value="Hand"></Setter> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="RadioButton"> |
|||
<Border Padding="15 5" x:Name="border" BorderBrush="#8080FF" Background="Transparent"> |
|||
<TextBlock Text="{TemplateBinding Content}" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> |
|||
</Border> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsChecked" Value="True"> |
|||
<Setter TargetName="border" Property="BorderThickness" Value="0 0 0 2"></Setter> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</UserControl.Resources> |
|||
<DockPanel> |
|||
|
|||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="0 10 0 10"> |
|||
<RadioButton Content="淘宝" IsChecked="True" x:Name="tbRb" Click="tbRb_Click" GroupName="rbtab"></RadioButton> |
|||
<RadioButton Content="京东" x:Name="jdRb" Click="jdRb_Click" GroupName="rbtab"></RadioButton> |
|||
<RadioButton Content="阿里巴巴" x:Name="albbRb" Click="albbRb_Click" GroupName="rbtab"></RadioButton> |
|||
</StackPanel> |
|||
|
|||
<hc:TabControl IsAnimationEnabled="True" IsTabFillEnabled="False" Name="tab" ShowCloseButton="True" DockPanel.Dock="Bottom"> |
|||
|
|||
</hc:TabControl> |
|||
</DockPanel> |
|||
</UserControl> |
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
using System.Windows.Data; |
|||
using System.Windows.Documents; |
|||
using System.Windows.Input; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Navigation; |
|||
using System.Windows.Shapes; |
|||
|
|||
namespace 齐越慧眼.UserControls |
|||
{ |
|||
/// <summary>
|
|||
/// BrowerTabPanelControl.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class BrowerTabPanelControl : UserControl |
|||
{ |
|||
public BrowerTabPanelControl() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
public void NewTab(string url) |
|||
{ |
|||
var item = new HandyControl.Controls.TabItem() { IsSelected = true }; |
|||
item.Closed += (e, s) => { |
|||
var obj = e as HandyControl.Controls.TabItem; |
|||
var brower= obj.Content as BrowerControl; |
|||
brower.Exit(); |
|||
|
|||
}; |
|||
BrowerControl browerControl = new BrowerControl(url,item); |
|||
item.Content = browerControl; |
|||
tab.Items.Add(item); |
|||
} |
|||
|
|||
private void tbRb_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
NewTab("https://www.taobao.com/"); |
|||
//web.Load("https://www.taobao.com/");
|
|||
} |
|||
|
|||
private void jdRb_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
NewTab("https://www.jd.com/"); |
|||
//web.Load("https://www.jd.com/");
|
|||
} |
|||
|
|||
private void albbRb_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
NewTab("https://www.1688.com/?spm=a26352.13672862.searchbox.1.27bf6ae2slybzR"); |
|||
//web.Load("https://www.1688.com/?spm=a26352.13672862.searchbox.1.27bf6ae2slybzR");
|
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue