在ViewModel中,我有一个ObservableCollection
对象,其中每个对象都具有string
属性。我想将此对象列表绑定到Label
控件,以便每个对象的字符串属性是Span
控件的Label
。这有可能吗?需要帮助
public class MyObject { public string Sentence { get; set; } } public class MyViewModel { public ObservableCollection<MyObject> Sentences { get; set; } }
我需要的xaml
这是绑定后我希望得到的
<Label x:Name="LblParagraph"> <Label.FormattedText> <FormattedString> <FormattedString.Spans> <Span Text="Sentence from MyObject 1"></Span> <Span Text="Sentence from MyObject 2"></Span> <Span Text="Sentence from MyObject 3"></Span> <Span Text="Sentence from MyObject i"></Span> <Span Text="Sentence from MyObject ObservableCollection.Count"></Span> </FormattedString.Spans> </FormattedString> </Label.FormattedText> </Label>
如何编写我的xaml视图以获取上述xml作为结果
在我的ViewModel中,我有一个对象的ObservableCollection,其中每个对象都有一个字符串属性。我想将此对象列表绑定到Label控件,以便每个对象的字符串属性...
也许我们不能直接在Xaml