码迷,mamicode.com
首页 > 其他好文 > 详细

Listbox简单用法

时间:2015-09-09 13:13:17      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

<ListBox x:Name="ListBoxPatientAllergy" Grid.Row="1"
ItemContainerStyle="{StaticResource ListboxStyle}"
Background="Transparent" BorderThickness="0"
Foreground="Black"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.PanningMode="None"
ItemsSource="{Binding Path=PatientAllergyEntityList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="170"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<sync:DateTimeEdit x:Name="dpPatientAllergy"
Height="28" Width="100" Margin="0,0,0,5"
DateTime="{Binding Path=Date, Mode=TwoWay}"
CustomPattern="dd MMM yyyy"
MinDateTime="01 Jan 1800"/>

<TextBox Name="TxtPatientAllergy" Grid.Column="1"
HorizontalAlignment="Stretch" Height="28"
MaxLength="100" Margin="2,0,0,5" VerticalContentAlignment="Center"
Validation.Error="Validation_Error"
Text="{Binding Path=Description,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>

<ComboBox Name="CmbPatientAllergy" Grid.Column="2" VerticalContentAlignment="Center"
ItemContainerStyle="{StaticResource ComboBoxItemStyle}"
Background="White" Margin="2,0,0,5" Height="28"
ItemsSource="{Binding RelativeSource={RelativeSource Findancestor, AncestorType={x:Type UserControl}}, Path=DataContext.CodeTables.CTPatientAllergyStatusEntityList}"
DisplayMemberPath="DisplayValue"
SelectedValuePath="PatientAllergyStatusID"
SelectedValue="{Binding Path=PatientAllergyStatusFK, Mode=TwoWay}"/>

<Button x:Name="BtnDeletePatientAllergy" Grid.Column="3"
Margin="2,2,2,5" BorderThickness="0" BorderBrush="White" HorizontalAlignment="Center"
Height="28" Width="30"
Click="BtnDeletePatientAllergy_Click">
<Button.Template>
<ControlTemplate TargetType="Button">
<Image Width="24" Height="24"
HorizontalAlignment="Center" VerticalAlignment="Center"
Source="pack://application:,,,/Medisys.SEMR.WPFClient.Controls.Resource;component/Image/DeleteIcon.png" />
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

 

事件:

private void BtnDeletePatientAllergy_Click(object sender, RoutedEventArgs e)
{
object obj = ((Button)sender).DataContext;

if (obj == null)
return;
else
{

PatientAllergyEntity PatientAllergyEntity = obj as PatientAllergyEntity;

if (PatientAllergyEntityList != null
&& PatientAllergyEntity.PatientAllergyID != null && PatientAllergyEntity.PatientAllergyID != Guid.Empty)
{
PatientAllergyEntityList.Remove(PatientAllergyEntity);
}

}
}

Listbox简单用法

标签:

原文地址:http://www.cnblogs.com/zhaowei303/p/4794176.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!