Custom Binding Path
-
I have to realize a binding like this
<TextBlock Text="{local:mybinding Path=folder1.folder2.item}" FontSize="16"/>
in the Path I have a string but this doesn't correspond to an object tree, I would dynamically attach a real object that corresponds to this string. example folder1.folder2.item1 I create an object obj1=new MyObject("folder1.folder2.item1") example folder1.folder2.item2 I create an object obj2=new MyObject("folder1.folder2.item2") obj1 and obj2 are the real objects I want bind. Maybe it's possible with ExtensionMarkup but Silverlight 3 doesn't support it, do it? Do you have any solution? -
I have to realize a binding like this
<TextBlock Text="{local:mybinding Path=folder1.folder2.item}" FontSize="16"/>
in the Path I have a string but this doesn't correspond to an object tree, I would dynamically attach a real object that corresponds to this string. example folder1.folder2.item1 I create an object obj1=new MyObject("folder1.folder2.item1") example folder1.folder2.item2 I create an object obj2=new MyObject("folder1.folder2.item2") obj1 and obj2 are the real objects I want bind. Maybe it's possible with ExtensionMarkup but Silverlight 3 doesn't support it, do it? Do you have any solution?Fabrizio Camagna wrote:
<TextBlock Text="{local:mybinding Path=folder1.folder2.item}" FontSize="16"/>
folder1.folder2.item is a path to a string or do you want to specify the string in markup?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Fabrizio Camagna wrote:
<TextBlock Text="{local:mybinding Path=folder1.folder2.item}" FontSize="16"/>
folder1.folder2.item is a path to a string or do you want to specify the string in markup?
Mark Salsbery Microsoft MVP - Visual C++ :java:
is a path that rappresent a tree path of my "custom namespace" but the objects don't exist before I parse this string. I'd like parse this string and create these objects.
-
is a path that rappresent a tree path of my "custom namespace" but the objects don't exist before I parse this string. I'd like parse this string and create these objects.
Maybe you could use a converter...
public class MyObject { public MyObject(string str) { //... } } public class StringToObjectConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string str = (string)parameter; return new MyObject(str); } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } <UserControl.Resources> <local:StringToObjectConverter x:Name="StringToObjectConverter" /> </UserControl.Resources>
...
<TextBlock Text="{Binding Converter={StaticResource StringToObjectConverter}, ConverterParameter=folder1.folder2.item}" FontSize="16"/>Mark Salsbery Microsoft MVP - Visual C++ :java: