1
我在ItemsControl中有一個Border,它需要從ItemsSource(Observable Collection)中名爲BorderColor的字段中獲取它的BorderBrush。在itemscontrol中的wpf borderbrush綁定
<ItemsControl ItemsSource="{Binding ObsColOfThings}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Border BorderThickness="3" BorderBrush="{Binding BorderColor}">
<ContentPresenter Content="{Binding}" />
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border >
<TextBlock Text="{Binding Text}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
綁定正在工作,但邊界刷沒有。
我也嘗試這樣做,它不會盡管做工精細
<ItemsControl ItemsSource="{Binding Appointments}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="{Binding BorderColor" BorderThickness="3">
<TextBlock Text="{Binding AppointmentDescription}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我要去哪裏錯了文字工作,要麼?