![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | XAML extension question In my application I want to display some data in a list box. I need to display the data as a picture. My 1st idea was to create a ValueConverter to convert my datas to ImageSource But this has a few problem, the biggest one is there is no parameter! So I though of MarkupExtension something like that: <ListBox ItemsSource={Binding Document.Maps}> <ItemTemplate> <Image Source="{local:Map2Image PreviewDpi=24, Background=false}" /> </ItemTemplate> </ListBox> but here, problem, in the Map2ImageExtension.ProvideValue(IServiceProvider) I don't ave the current data, worst, I have no idea to get it. I was able to get the IProvideValueTarget but it only knows about the "Image" object, not about the current item. I tried to look into the "Binding" and "BindingBase" code with reflector, but I don't understand what's going on... Any tip? Otherwise I could write a specialized viewer FrameworkElement, but I though of using MarkupExtension might be a nice way to solve the problem.... |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: XAML extension question Hi Lloyd I don't have an answer to your problem. Sorry. But today I have the same problem and don't know how to get the instance of the ServiceProvider. In my case I want get the "ObjectDataProvider" How can tell us how we can get our ServiceObjects? My Xaml: <ObjectDataProvider x:Key="VitoPatient" ObjectType="{x:Type VFC:GetDataCommand}" MethodName="Execute"> ..... <StackPanel VFW esignView.DataContext="{BindingSource={VFW:MyDynamicResource VitoPatient}, Path=ParentObjects[Person__Patient]}"> ..... My Class: <MarkupExtensionReturnType(GetType(Object)), TypeConverter(GetType(DynamicResourceExtensionConverter))> _ Public Class MyDynamicResource Inherits System.Windows.DynamicResourceExtension Public Overrides Function ProvideValue(ByVal serviceProvider As System.IServiceProvider) As Object If (Not VitoResourceManager.DesignMode) Then If (GetType(ObjectDataProvider).IsInstanceOfType(serviceProvider)) Then Return MyBase.ProvideValue(serviceProvider) Else Return MyBase.ProvideValue(serviceProvider) End If Else Return VitoApplication.FindDynamicResource(Me.ResourceKey.ToString) End If End Function Public Sub New() MyBase.New() End Sub Public Sub New(ByVal resourceKey As Object) MyBase.New(resourceKey) End Sub End Class |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: XAML extension question Hi, -- > Hi Lloyd > > > I don't have an answer to your problem. Sorry. > But today I have the same problem and don't know how to get the instance > of > the ServiceProvider. > > In my case I want get the "ObjectDataProvider" > How can tell us how we can get our ServiceObjects? > > when I read you VB code it looks a bit strange to me... :-/ anyway here is pseudo C# code (i.e. from the top of my head) to lookup for object by name (define before the object using this markp extension, same restriction as in StaticResource) class MyMarkup : MarkupExtension { public object ProvideValue(IServiceProvider sp) { if(sp == null) return null IProvideValueTarget pvt = (IProvideValueTarget)sp.GetService(typeof(IProvideValueTarget)); if(pvt == null) return null; FrameworkElement fe = pvt.Target as FrameworkElement; if(fe == null) return null; DependencyObject do = fr.FindName("aName"); // ... whatever you need to ... } } |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: XAML extension question Hi Lloyd Thanks a lot that looks good to get the TargetObjetct. But How can I get the Source? In my case the <ObjectDataProvider x:Key="VitoPatient" ObjectType="{x:Type VFC:GetDataCommand}" MethodName="Execute"> Best regards Horst |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: XAML extension question mmhh... I don't understand the question?.. what is this source you talk about? anyway your only hope is a FindName() (or FindResource()) call to get other object on the UI. Binding use an internal Expression class which sets up event listener and can "Horst Klein" <HorstKlein@discussions.microsoft.com> wrote in message news:47CB3366-391E-462B-A550-BE9D978813DC@microsoft.com... > Hi Lloyd > > Thanks a lot that looks good to get the TargetObjetct. > > But How can I get the Source? > > In my case the > <ObjectDataProvider x:Key="VitoPatient" ObjectType="{x:Type > VFC:GetDataCommand}" MethodName="Execute"> > > Best regards Horst |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: XAML extension question Hi, back to your original point. Surely you can pass a parameter to a ValueConverter, using the ConverterParameter argument in the binding expression. If you need to pass multiple parameters, you could parse a string or use array-extension to pass in an array as parameter. cheers Florian |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: XAML extension question Hi, back to your original point. Surely you can pass a parameter to a ValueConverter, using the ConverterParameter argument in the binding expression. If you need to pass multiple parameters, you could parse a string or use array-extension to pass in an array as parameter. cheers Florian |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: XAML extension question Yea, I saw that. I was just mistakenly assuming that the Converter property took a TypeConverter, whereas, as I later realized, it takes an IValueConverter (which is different, of course). anyway, this problem is long solved!! ;-) "Florian Kruesch" <nospam@kruesch.de> wrote in message news:468E7C81.1030404@kruesch.de... > Hi, > > back to your original point. Surely you can pass a parameter to > a ValueConverter, using the ConverterParameter argument in the binding > expression. If you need to pass multiple parameters, you could parse > a string or use array-extension to pass in an array as parameter. > > cheers > Florian |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Is it possible to include XAML files into another XAML file? | star-italia | .NET General | 6 | 06-12-2008 04:56 AM |
| Extension Method Question for ServicedComponent | coconet | .NET General | 1 | 04-06-2008 03:23 PM |
| Simple XAML Question ! | MarkS | Avalon | 8 | 01-12-2007 11:10 AM |
| How to deploy an XAML-based App with its XAML-UI-File? | Solveigh | Avalon | 11 | 11-08-2006 07:50 AM |
| Question about Listview, XAML, and hover. | Whitey | Avalon | 0 | 10-11-2006 10:48 AM |