wpf - In XAML bind Text to x index of static collection with x being supplied by the y index of another collection? -
I have a steady collection of strings and display one of these strings with a certain index. That index is supplied at the time of running, and the second collection contains an integer value in the second index.
I can share in the stable collection, but how do I bind the path of value in the second collection? That is, What do I use as a value for path logic in TextBlock binding? The code here is for use and it is not part of the code, it is compatible with the Visual Studio Designer, and if I get the binding rights, then it will be running on Wednesday without the running designer Will show in: Fixed class: The class supplying the index value: } Nothing has been added in the code behind the XML. Thanks for reading. David Did you consider using a dictionary?
& lt; Window x: Class = "Biding Collection Index. Manvindo" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/ 2006 / xaml "xmlns: local =" clr-namespace: binding collection index "title =" main window "height =" 350 "width =" 525 "& gt; & Lt; Window.Resources & gt; & Lt; Local: Other class x: key = "foo" /> & Lt; /Window.Resources> & Lt; Grid & gt; & Lt; TextBlock Text = "{binding source = {x: static locale: MyStaticCollections.Days}, path = [** false ... Foo.CollectionOfIntegers [2] **]}" /> & Lt; / Grid & gt;
using System.Collections.Generic; Namespace Binding Collection Index {Fixed class MyStaticCollections {public static list & lt; String & gt; Days = new list & lt; String & gt; { "Monday Tuesday Wednesday Thursday Friday" }; }}
using System.Collections.ObjectModel; Namespace binding collection index {class other class {private obsovable collection & lt; Int & gt; CollectionOfIntegers = New Observational Collection & lt; Int & gt; {1,2,3,4,5}; Public Supervision Collection & lt; Int & gt; CollectionOffers {Receive {archive collection recipients; }}}
class day view model {public idictionary & lt; Int, string & gt; Day {receipt; Set; } Public DaysViewModel () {days = new dictionary & lt; Int, string & gt; {{1, "Monday"}, {2, "Tuesday"}, {3, "Wednesday"}, {4, "Thursday"}, {5, "Friday"}}; 8} Winfx / 2006 / xaml "xmlns: local =" clr-namespace: WpfApplication1 "heading =" main window "height =" 350 "width =" 525 "& gt; & gt; Window.Resources & gt; & lt; Local: Day view MODEL x: key = "week" />
Comments
Post a Comment