에있는 ListView에서 ListboxItems를 바인더 제본하는 방법을 나는 는 WPF
나는 다음과 같은 XmlDataProvider 소스에 바인더 제본되는 세 개의 열이있는 목록보기가 ... WPF 그래서 어떤 바보 같은 질문에 대한 실례에 아주 새로운 해요 : <XmlDataProvider x:Key="Properties" XPath="/Info">
<x:XData>
<Info xmlns="">
<Property Name="Text" Value=""/> <!--0-->
<Property Name="Tooltip" Value=""/> <!--1-->
<Property Name="Enable" Value=""/> <!--2-->
<Property Name="Visible" Value=""/> <!--3-->
<Property Name="Focus" Value=""/> <!--4-->
<Property Name="Selected" Value=""/> <!--5-->
<Property Name="Count" Value=""/> <!--6-->
<Property Name="Item" Value=""/> <!--7-->
<Property Name="SelectedText" Value=""/> <!--8-->
<Property Name="SelectedIndex" Value=""/> <!--9-->
<Property Name="Complete" Value=""/> <!--10-->
</Info>
</x:XData>
</XmlDataProvider>
이 목록보기는 다음과 같이 정의된다 :
<ListView Name="lstProperties" Margin="55 0 0 0" Style="{DynamicResource TsListView}"
Grid.Row="2" Grid.RowSpan="7" Grid.ColumnSpan="4"
ItemsSource="{Binding Source={StaticResource Properties}, XPath=Property}"
ItemContainerStyle="{DynamicResource TsListViewItem}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
SelectionMode="Single" IsEnabled="False"
SelectionChanged="propertySelected"
>
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn CellTemplate="{StaticResource FirstCell}" Width="25" />
<GridViewColumn Header="Property" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Style="{DynamicResource TsLabel}" Height="25" Width="115" Content="{Binding [email protected]}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Value" Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{DynamicResource TsHelperTextBox}"
Height="20" Width="115" Text="{Binding [email protected]}"
IsEnabled="{Binding ElementName=rbTypeAssert, Path=IsChecked}" GotFocus="gridTextBox_GotFocus" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
내가 지금하고 싶은 것은 매우 간단하다 : 난 그냥 활성화/ListViewItems의 일부를 해제 할. 내가 ListViewItems를 얻을 발견하는 유일한 방법은 다음과 같은 방법을 통해 :
lstProperties.ItemContainerGenerator.ContainerFromIndex(index)
이 날 조금 불편합니다. 속성의 이름 속성을 통해 항목을 가져와야합니다. 이 작업을 수행 할 여지가 있습니까? 또한 창을 초기화 한 후에 바로이 작업을 수행하려고하면 문제가 발생합니다. 이러한 ListViewItem 중 하나를 사용하지 않도록 설정하려고하면 NullReferenceException이 발생합니다. 윈도우가 렌더링 된 직후 바인딩이 아직 완료되지 않은 것 같습니다.
이<ListView>
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsEnabled" Value="{Binding YourProperty}"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
감사합니다, 내가 뭔가 생각했습니다 이런 식으로 3 가지 문제가있었습니다. . 1. 어떻게 사용자 정의 속성 (OK 이것은 초보자 질문은 정말) 정의하는 2. 나는 이미 내 응용 프로그램의 모든 ListViewItems에 대해 정의 된 스타일을 가지고있다. 솔루션이 나는이 ListViewItems에 대한 특정 스타일을 가지고해야? 내가있는 ListViewItem 당 하나 개의 속성이 아니라 하나의 일반 속성을 필요로이 특정 상황에서 3, 가장 중요한 것을 의미한다. XmlDataSource에서 바인딩 할 수 있습니까? 감사합니다. – jpsstavares