1.依赖属性
<controls:ControlWindow x:Class="DF.Client.Layout.UserView.UserManage"
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:DF.Client.Layout"
xmlns:controls="clr-namespace:DF.Client.Contorls"
xmlns:common="clr-namespace:DF.Client.Common"
mc:Ignorable="d"
d:DesignWidth="1251" d:DesignHeight="800" >
<Grid>
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderThickness="0,0,0,1" BorderBrush=" #FFB6BBBD" Background="{DynamicResource contenttopbarbg}">
<DockPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="{DynamicResource marginleft15}">
<Label Content="用户名:"/>
<TextBox x:Name="tbx_UserAccount" Width="120" />
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="{DynamicResource marginleft15}">
<Label Content="中文名:"/>
<TextBox x:Name="tbx_UserName" Width="120" />
</StackPanel>
<Button Content="查询" Click="click_Query" Width="60" Margin="{DynamicResource marginleft15}" Style="{DynamicResource btn_dif_gray}"/>
<TextBlock VerticalAlignment="Center" Margin="{DynamicResource marginleft15}" Foreground="#FF58595B"><Run Text="共 " /><Run Text=" "/><Run x:Name="total"/><Run Text=" "/><Run Text=" 条数据" /></TextBlock>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Name="btnAdd" Height="30" Command="{x:Static ApplicationCommands.New}" Margin="{DynamicResource marginright20}" Style="{DynamicResource btn_ico}" Tag="新增">
<Grid Height="16" Width="16">
<Path Stretch="Fill" Fill="White" Data="F1 M 397.333,281.333L 393.333,281.333L 393.333,285.333L 390.667,285.333L 390.667,281.333L 386.667,281.333L 386.667,278.667L 390.667,278.667L 390.667,274.667L 393.333,274.667L 393.333,278.667L 397.333,278.667L 397.333,281.333 Z " Width="12" Height="12"/>
</Grid>
</Button>
</StackPanel>
</DockPanel>
</Border>
<DataGrid Grid.Row="1" Margin="0,0,1,0" x:Name="UserInfomationTable" ItemsSource="{Binding}" Style="{DynamicResource DataGridStyle2}" VerticalContentAlignment="Center" RowStyle="{DynamicResource DataGridRowStyle}" CanUserAddRows="False" UseLayoutRounding="False" ScrollViewer.CanContentScroll="True" AutoGenerateColumns="False" RowHeaderStyle="{DynamicResource DataGridRowHeaderStyle}" CellStyle="{DynamicResource DataGridCellStyle}" IsSynchronizedWithCurrentItem="False" HeadersVisibility="All">
<DataGrid.Columns>
<DataGridTextColumn Width="200" Header="用户名" Binding="{Binding Account}"/>
<DataGridTextColumn Width="200" Header="中文名" Binding="{Binding Name}"/>
<DataGridTextColumn Width="200" Header="电话" Binding="{Binding Phone}"/>
<DataGridTextColumn Width="200" Header="电子邮件" Binding="{Binding EMail}"/>
<DataGridTemplateColumn Width="*" Header="操作">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<Button Style="{DynamicResource btn_sp}" Command="{x:Static common:AppCommands.Edit}" CommandParameter="{Binding Id}" ToolTip="编辑" IsEnabled="{Binding IsEditAuth}">
<Image Source="/DF.Client;component/Resource/Images/ico_bj.png" Stretch="None"/>
</Button>
<Button Style="{DynamicResource btn_sp}" Command="{x:Static common:AppCommands.Delete}" CommandParameter="{Binding Id}" ToolTip="删除" IsEnabled="{Binding IsDelAuth}">
<Image Source="/DF.Client;component/Resource/Images/ico_sc.png" Stretch="None"/>
</Button>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>
</controls:ControlWindow>
public partial class UserManage : ControlWindow
{
……
public bool IsAddEditDelAuth
{
get { return (bool)GetValue(IsAddEditDelAuthProperty); }
set { SetValue(IsAddEditDelAuthProperty, value); }
}
// Using a DependencyProperty as the backing store for IsAddEditDelAuth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsAddEditDelAuthProperty =
DependencyProperty.Register("IsAddEditDelAuth", typeof(bool), typeof(UserManage), new PropertyMetadata(false));
}