나는이 내 XAML에서 다음 별자리 :미리보기 X 않고 DataTemplate을 : 목록 상자에 바인딩 키를 사용하여 Expression Blend를 샘플 데이터
다음의 DataTemplate은 데이터 형식을 통해 적용<ListBox x:Uid="attributesListBox"
DataContext="{Binding Source={StaticResource EditFeatureWithForeignKeyAttributesViewModel}}" ItemsSource="{Binding Path=Attributes}"
d:DataContext="{d:DesignData /SampleData/BlendableAttributesSampleData.xaml}">
</ListBox>
:
<DataTemplate x:Uid="dataColumnFeatureAttributeDataTemplate" DataType="{x:Type DataColumnFeatureAttribute}">
<!-- ... opens a button and a grid ... -->
<TextBlock Text="{Binding EditCaption}" />
<!-- ... closes button and grid ... -->
</DataTemplate>
"설명"절의 here에서 설명한 것처럼 x : Key는 암시 적으로 생성되며 "DataTemplate은 해당 유형의 데이터 개체에 자동으로 적용됩니다."
DataTemplate 내부에는 목록 항목의 몇 가지 간단한 속성이 바인딩됩니다.
<SampleData:BlendableAttributes xmlns:SampleData="clr-namespace:Commons.Mobile.SampleData">
<SampleData:BlendableAttributes.Attributes>
<Mobile_Client:FeatureAttribute DisplayCaption="Vestibulum adipiscing curabitur" DisplayString="Class maecenas parturient" ErrorMessage="Nunc amet aliquam nam sed" EditCaption="Cras phasellus duis" IsEditable="True" IsSearchable="False" IsViewable="True" Modified="False">
<Mobile_Client:FeatureAttribute.Feature>
<!-- ... Feature with a lot of properties ... -->
</Mobile_Client:FeatureAttribute.Feature>
</Mobile_Client:FeatureAttribute>
<!-- ... more FeatureAttributes ... -->
</SampleData:BlendableAttributes.Attributes>
</SampleData:BlendableAttributes>
을 DataTemplate을 미리보기에서 올바르게 적용되어, 내가 경우 : 그것은 간단한 문자열, 그리고 목록 상자의 DataContext에와 ItemsSource가 맞아야합니다 - 내 샘플 데이터에서이 발췌에서는 EditCaption 속성은 위에서 언급 찾을 수 그것을 x : Key를 통해 참조하십시오. 이 경우에는 목록에 여러 유형의 개체가 포함되어 있으므로 불가능합니다. 따라서 암시 적 x : Key를 사용하여 개체 유형에 따라 특정 DataTemplate을 적용해야합니다.
그래서 내 VM의 데이터와 실행시 아무 문제가 없다,하지만 전체 페이지에
- 익스프레션 블렌드는하지만, DataTemplate을을 적용하지 않고 샘플 데이터를 보여줍니다 반면에, 내가 Resources로 가서 DataTemplate을 편집하면, SampleData없이 레이아웃을 볼 수있다.
나는 몇 가지 시도를 해본 결과 포럼에서 해결책을 찾았지만 아무도이 특별한 별자리를 갖고있는 것 같지 않습니다. 누군가 나를 기쁘게 도와 줄 수 있습니까?
안녕과 답변이 늦어 죄송합니다 - 나는 당신의 대답을 알고하지 않았다 지금까지 . 아쉽게도 내 시스템 구성이 변경되어 라이센스 문제로 인해 해당 프로젝트를 더 이상 빌드 할 수 없습니다. 작은 데모 응용 프로그램에서 같은 별자리를 만들었을 때 전혀 문제가 없었습니다. DataTemplate은 DesignData로 설정된 SampleData의 빌드 유형으로도 DataType에 의해 자동으로 적용됩니다. 큰 프로젝트에서 어리석은 부작용이되었을 수도 있습니다. 어쨌든, 도와 줘서 고마워! – pnolle