11 changed files with 187 additions and 26 deletions
@ -0,0 +1,62 @@ |
|||
<UserControl x:Class="BBWY.Client.Views.SelectShop.SelectShopDialog" |
|||
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:local="clr-namespace:BBWY.Client.Views.SelectShop" |
|||
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" |
|||
mc:Ignorable="d" |
|||
x:Name="uc" |
|||
d:DesignHeight="200" d:DesignWidth="300"> |
|||
<Grid> |
|||
<Border x:Name="bd" BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" MinWidth="100" Height="{Binding ActualHeight,ElementName=uc}" Background="White" Margin="5,0,0,0" |
|||
PreviewMouseLeftButtonDown="bd_PreviewMouseLeftButtonDown"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition/> |
|||
<ColumnDefinition Width="auto"/> |
|||
</Grid.ColumnDefinitions> |
|||
<TextBlock x:Name="txtShopName" Text="" Margin="5,0,0,0" VerticalAlignment="Center"/> |
|||
<!--<c:BButton Grid.Column="1" Background="Transparent" HorizontalAlignment="Right" Margin="5,0"> |
|||
|
|||
</c:BButton>--> |
|||
<Path Style="{StaticResource path_arrowDown}" |
|||
Width="10" Grid.Column="1" Margin="5,0"/> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Popup x:Name="popup" Placement="Bottom" PlacementTarget="{Binding ElementName=bd}" StaysOpen="True" |
|||
AllowsTransparency="True"> |
|||
<Border BorderBrush="{StaticResource Border.Brush}" BorderThickness="1" Background="White"> |
|||
<StackPanel Margin="10"> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<TextBlock Text="团队" HorizontalAlignment="Right" VerticalAlignment="Center"/> |
|||
<ComboBox x:Name="cbx_department" |
|||
ItemsSource="{Binding DepartmentList,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}}}" |
|||
SelectedIndex="0" |
|||
DisplayMemberPath="Name" |
|||
Width="150" Height="25" |
|||
HorizontalAlignment="Left" VerticalContentAlignment="Center" |
|||
Grid.Column="1" Margin="5,0,0,0" |
|||
SelectionChanged="cbx_department_SelectionChanged"/> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Horizontal" Margin="0,10,0,0"> |
|||
<TextBlock Text="店铺" HorizontalAlignment="Right" Grid.Row="1" VerticalAlignment="Center" /> |
|||
<ComboBox x:Name="cbx_shop" Width="150" Height="25" |
|||
SelectedIndex="0" |
|||
HorizontalAlignment="Left" VerticalContentAlignment="Center" |
|||
DisplayMemberPath="ShopName" |
|||
Grid.Column="1" Grid.Row="1" Margin="5,0,0,0"/> |
|||
|
|||
</StackPanel> |
|||
|
|||
<c:BButton x:Name="btn_ok" Content="确定" Grid.Row="2" Width="60" Height="25" HorizontalAlignment="Right" |
|||
Click="btn_ok_Click" Margin="0,10,0,0"/> |
|||
</StackPanel> |
|||
</Border> |
|||
</Popup> |
|||
|
|||
|
|||
</Grid> |
|||
</UserControl> |
@ -0,0 +1,66 @@ |
|||
using BBWY.Client.Models; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace BBWY.Client.Views.SelectShop |
|||
{ |
|||
/// <summary>
|
|||
/// SelectShopDialog.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class SelectShopDialog : UserControl |
|||
{ |
|||
|
|||
public Shop Shop { get; set; } |
|||
|
|||
public static readonly DependencyProperty DepartmentListProperty = DependencyProperty.Register("DepartmentList", typeof(IList<Department>), typeof(SelectShopDialog)); |
|||
public static readonly RoutedEvent OnShopChangedEvent = EventManager.RegisterRoutedEvent("OnShopChanged", RoutingStrategy.Bubble, typeof(EventHandler<OnShopChangedEventArgs>), typeof(SelectShopDialog)); |
|||
|
|||
public IList<Department> DepartmentList |
|||
{ |
|||
get { return GetValue(DepartmentListProperty) as IList<Department>; } |
|||
set { SetValue(DepartmentListProperty, value); } |
|||
} |
|||
|
|||
public event RoutedEventHandler OnShopChanged |
|||
{ |
|||
add { this.AddHandler(OnShopChangedEvent, value); } |
|||
remove { this.RemoveHandler(OnShopChangedEvent, value); } |
|||
} |
|||
|
|||
public SelectShopDialog() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void cbx_department_SelectionChanged(object sender, SelectionChangedEventArgs e) |
|||
{ |
|||
var d = cbx_department.SelectedItem as Department; |
|||
cbx_shop.ItemsSource = d.ShopList; |
|||
cbx_shop.SelectedIndex = 0; |
|||
} |
|||
|
|||
private void btn_ok_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
popup.IsOpen = false; |
|||
Shop = cbx_shop.SelectedItem as Shop; |
|||
txtShopName.Text = Shop.ShopName; |
|||
var args = new OnShopChangedEventArgs(OnShopChangedEvent, this); |
|||
args.SelectedShop = Shop; |
|||
this.RaiseEvent(args); |
|||
} |
|||
|
|||
private void bd_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) |
|||
{ |
|||
popup.IsOpen = true; |
|||
} |
|||
} |
|||
|
|||
public class OnShopChangedEventArgs : RoutedEventArgs |
|||
{ |
|||
public OnShopChangedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { } |
|||
|
|||
public Shop SelectedShop { get; set; } |
|||
} |
|||
} |
@ -1,4 +1,4 @@ |
|||
<c:BWindow x:Class="BBWY.Client.Views.SelectShop" |
|||
<c:BWindow x:Class="BBWY.Client.Views.SelectShopW" |
|||
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" |
Loading…
Reference in new issue