0
ListBox
컨트롤을 코드 뒤에 넣으려고합니다. 다음 코드는 내가 쓴 : 목록 상자 항목의 내용을 변경하는wpf에서 코드 뒤에 Listbox 컨트롤을 얻는 방법
<ListBox x:Name="listbox" Grid.Column="0" SelectedIndex="0" BorderThickness="0" Style="{StaticResource myListboxStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Hidden" ItemsSource="{Binding IsAsync=True}" DataContext="{Binding IsAsync=True}" ItemStringFormat="{Binding IsAsync=True}" BorderBrush="Black" IsEnabled="True">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid x:Name="gridEmployee" Height="90" Margin="1,0,0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="25" />
</Grid.ColumnDefinitions>
<Grid x:Name="pic" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="8,8,0,8">
<Border Name="mask" CornerRadius="7" removed="White" />
<Image x:Name="imgEmp" Height="50" Width="50" Stretch="Fill">
<Image.OpacityMask>
<VisualBrush Visual="{Binding ElementName=mask}"/>
</Image.OpacityMask>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="{Binding Path=PicPhoto, IsAsync=True}"></Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=PicPhoto, IsAsync=True}" Value="{x:Null}">
<Setter Property="Source" Value="/TimeAttendance_PageTransition;component/Images/blank.jpg" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
<StackPanel Name="spEmpData" Margin="5,6,0,0" Width="206" Grid.Column="1">
<TextBlock Name="tbEmpName" TextBlock.FontWeight="Bold" Text="{Binding Path=Staff_Name_e, IsAsync=True}" Margin="0,6,0,0" FontSize="22" FontFamily="Browallia New">
<TextBlock.Effect>
<DropShadowEffect Color="White" BlurRadius="2" Direction="280" ShadowDepth="2"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Name="tbPunchDate" Text="{Binding Path=Punch_Date, IsAsync=True}" Margin="0,0,0,0" FontSize="13" Foreground="#FF545454">
<TextBlock.Effect>
<DropShadowEffect Color="White" BlurRadius="2" Direction="280" ShadowDepth="2"/>
</TextBlock.Effect>
</TextBlock>
<TextBlock Name="tbEmpCode" Text="{Binding Path=Emp_Code, IsAsync=True}" Margin="0,3,0,0" FontSize="13" Foreground="#FF545454">
<TextBlock.Effect>
<DropShadowEffect Color="White" BlurRadius="2" Direction="280" ShadowDepth="2"/>
</TextBlock.Effect>
</TextBlock>
</StackPanel>
<Canvas Grid.Column="2">
<Ellipse Margin="0,11,0,0" Height="18" Width="18" Opacity="1" VerticalAlignment="Top" HorizontalAlignment="Center" d:LayoutOverrides="Width">
<Ellipse.Fill>
<LinearGradientBrush EndPoint="0.0,0.1" StartPoint="0.0,0.0">
<GradientStop Color="{Binding Path=Function_Key, IsAsync=True}" Offset="1"/>
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
</Canvas>
</Grid>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
<Setter TargetName="tbEmpName" Property="Foreground" Value="Black"/>
<Setter TargetName="tbEmpCode" Property="Foreground" Value="Black"/>
<Setter TargetName="tbPunchDate" Property="Foreground" Value="Black"/>
<Setter TargetName="gridEmployee" Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="{DynamicResource {x:Static SystemColors.GradientActiveCaptionColorKey}}" Offset="0"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
이것은 ListBox
, 나는 뒤에 코드에서 ListBox
내부 통제를 원하는 내된다. 코드 뒤에서 ListBox
컨트롤 ('목록 상자')을 얻었지만 Image
('imgEmp') & 텍스트 블록이 코드 숨김으로 표시되지 않았습니다.
필자는 분명히 VB에서 컨트롤 배열과 같은 목록 상자 항목을 제어하려고합니다. 어떻게해야합니까?
미리 감사드립니다.