제목을 정확하게 설명하지 못하기 때문에 제목이 정확하지 않을 수도 있습니다.WPF : 변환 된 개체에 바인딩하지 못했습니다!
public partial class NSLTextBlock: UserControl
{
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
}
public object HighlightMatchCase
{
get { return GetValue(HighlightMatchCaseProperty); }
set
{
SetValue(HighlightMatchCaseProperty, value);
}
}
public static readonly DependencyProperty HighlightMatchCaseProperty =
DependencyProperty.Register(
"HighlightMatchCase",
typeof(object),
typeof(NSLTextBlock),
new PropertyMetadata(null, new PropertyChangedCallback(HighlightChangedCallback)));
public NSLTextBlock()
{
InitializeComponent();
}
}
}
그리고 이은 종속성 속성입니다 HighlightMatchCase :
나는 아래 NSLTextBlock의 정의는, NSLTextBlock라는 이름의 사용자가 제어 할 수 있습니다. 이 같은
호스트보기 :
<ListView Name ="LogDataList" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding LogDataCollection}" Background="Cyan">
<ListView.View>
<GridView AllowsColumnReorder="true"
ColumnHeaderToolTip="Event Log Information">
<GridViewColumn Header="Event Log Name" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<l:NSLTextBlock Height="25" DataContext="{Binding LogName, Converter={StaticResource DataFieldConverter}}" HighlightMatchCase="{Binding Element}" Loaded="EditBox_Loaded"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Creator" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<l:NSLTextBlock Height="25" DataContext="{Binding CreatorName, Converter={StaticResource DataFieldConverter}}" HighlightMatchCase="{Binding Element}" Loaded="EditBox_Loaded"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Message" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<l:NSLTextBlock Height="25" DataContext="{Binding Message, Converter={StaticResource DataFieldConverter}}" HighlightMatchCase="{Binding Element}" Loaded="EditBox_Loaded"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
수 DataField :
public class DataField : INotifyPropertyChanged
{
private HighlightElement element;
public HighlightElement Element
{
get
{ return element; }
set
{
element = value;
OnPropertyChanged("Element");
}
}
}
는 사실, 난 문자열을 DataField에 (예 : LOGNAME, CreatorName 및 메시지 등)과 내 자신을 바인딩 변환 할 정의 된 속성 (HighlightMatchCase) ~ 요소 (변환 된 datacontext). Element에 바인딩 할 때 BindingExpressionException이 발생하고 객체의 'Element'속성을 찾을 수 없습니다.
어떻게 해결할 수 있습니까? 당신의 제안은 무엇입니까?
정말 고맙습니다. 온라인.
http://bea.stollnitz.com/blog/?p=52를 시도하고 더 자세한 오류가 있는지 확인하십시오. – JustABill