목록 상자의 DataTemplate을 컨트롤의 내부 UserControl을 바인딩 :다음과 같이 I 사용자 컨트롤이 실버
public string CaseTitle
{
get { return (string)GetValue(TitleProperty); }
set {
SetValue(TitleProperty, value); }
}
// Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("CaseTitle", typeof(string), typeof(SearchResultControl), new PropertyMetadata(new PropertyChangedCallback(SearchResultControl.OnValueChanged)));
내 .xaml에서 : CaseTitle에 대한 종속성 속성을
<UserControl x:Class="CaseDatabase.Controls.SearchResultControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="192" d:DesignWidth="433">
<Grid x:Name="LayoutRoot" Background="White" Height="230" Width="419">
<Grid.RowDefinitions>
<RowDefinition Height="68*" />
<RowDefinition Height="90*" />
</Grid.RowDefinitions>
<TextBlock x:Name="TitleLink" Height="33" Text="{Binding CaseTitle}" HorizontalAlignment="Left" Margin="12,12,0,0" VerticalAlignment="Top" Width="100" Foreground="Red"/>
</Grid>
을 페이지 목록 상자가 있고 그것의 데이터 형식 안에 내 컨트롤을 instanciate. 이 목록 상자의 ItemsSource는 도메인 서비스에 바인딩됩니다. 바인딩 작업을 알면 적절한 수의 elemets를 얻을 수 있지만 데이터가 전혀 표시되지 않습니다.
내 목록 상자에 대한 코드는 다음과 같다 :
<ListBox x:Name="SearchResultsList" Width="Auto" MinHeight="640" ItemsSource="{Binding ElementName=SearchDomainDataSource, Path=Data}"
Grid.Row="0" Grid.Column="0">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid x:Name="LayoutRoot" Background="White" Height="158" Width="400">
<my:SearchResultControl CaseTitle="{Binding Path=Title}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
그래서 누군가가 내가 엉망으로하고 방법을 제안 할 수 있습니다 내 내 사용자 컨트롤에 바인딩? 감사합니다
대단히 감사합니다. 완벽하게 작동합니다. – Andres