0
我有一個使用模板顯示覆選框的ListView。我無法弄清楚如何將它綁定到MapName屬性的數據綁定。任何幫助將不勝感激。無論如何,如果複選框被選中,那麼ListView就會被排序?如何將風格化的ListView數據綁定到特定的字段?
<Window.Resources>
<ControlTemplate x:Key="ItemTemplate" TargetType="ListViewItem">
<Border
BorderThickness="{TemplateBinding Border.BorderThickness}"
Padding="{TemplateBinding Control.Padding}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True"
>
<ContentPresenter
Content="{TemplateBinding ContentControl.Content}"
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
/>
</Border>
</ControlTemplate>
<Style TargetType="ListViewItem">
<Setter Property="Template" Value="{StaticResource ItemTemplate}" />
</Style>
<DataTemplate x:Key="ItemDataTemplate">
<CheckBox
x:Name="checkbox"
Content="{Binding}"
IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}, Path=IsSelected}"
Foreground="{DynamicResource WhiteToLightGrayFlatBrush}"
/>
</DataTemplate>
</Window.Resources>
<Border Grid.Row="7" BorderThickness="0,1,0,0" Margin="0,0,0,0" Padding="1,3,3,3"
BorderBrush="{DynamicResource GrayBorderBrush}" >
<StackPanel Orientation="Vertical">
<Label HorizontalAlignment="Left"
Content="Selected Maps:"
Foreground="{DynamicResource WhiteToLightGrayFlatBrush}"
Style="{StaticResource LabelDefaultTransparentBkgr}" />
<ListView
x:Name="mListView"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Background="Transparent"
SelectionMode="Multiple"
MinHeight="73"
MaxHeight="73"
ItemTemplate="{StaticResource ItemDataTemplate}"/>
</StackPanel>
</Border>
謝謝!
戴夫