안녕하세요, 저는 ComboBox에서 바인딩 문제가 있습니다. ComboBox 항목을 ListView 열에 바인딩하고 선택한 값으로 선택한 열에 정의 된 연결된 속성의 값을 반환하고 싶습니다.ComboBox에서 'SelectedValuePath'로 '연결된 속성'을 정의하는 방법은 무엇입니까?
아래 예제에서는 선택한 열의 너비를 표시하는 작업 예제를 볼 수 있습니다. 당신이 에 콤보 상자에 SelectedValuePath을 변경 (LOC : SampleBehavior.SampleValue)하려고하면 :
BindingExpression 경로 오류 :을 당신은 바인딩 오류 '(유 : SearchableListView.SearchMemberPath)'속성 '개체'를 찾을 수 없습니다 ''GridViewColumn '
<Window x:Class="Problem_Sample1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="clr-namespace:Problem_Sample1" WindowStartupLocation="CenterScreen" Title="Window1" Height="300" Width="300"> <DockPanel> <ComboBox DockPanel.Dock="Top" x:Name="combobox" ItemsSource="{Binding Path=View.Columns, ElementName=listview}" DisplayMemberPath="Header" SelectedValuePath="Width"> </ComboBox> <StatusBar DockPanel.Dock="Bottom"> <TextBlock> <TextBlock Text="Selected column (value): " /> <TextBlock Text="{Binding Path=SelectedValue, ElementName=combobox}" /> </TextBlock> </StatusBar> <ListView x:Name="listview"> <ListView.View> <GridView> <GridViewColumn Header="Name" Width="101" loc:SampleBehavior.SampleValue="201" /> <GridViewColumn Header="Surname" Width="102" loc:SampleBehavior.SampleValue="202" /> </GridView> </ListView.View> </ListView> </DockPanel> </Window>
SampleBehavior.cs
어떤 도움이나 제안에 대한using System.Windows; using System.Windows.Controls; namespace Problem_Sample1 { public static class SampleBehavior { public static readonly DependencyProperty SampleValueProperty = DependencyProperty.RegisterAttached( "SampleValue", typeof (int), typeof (SampleBehavior)); [AttachedPropertyBrowsableForType(typeof(GridViewColumn))] public static int GetSampleValue(GridViewColumn column) { return (int)column.GetValue(SampleValueProperty); } [AttachedPropertyBrowsableForType(typeof(GridViewColumn))] public static void SetSampleValue(GridViewColumn column, int value) { column.SetValue(SampleValueProperty, value); } } }617,451,515,는
감사합니다.