473,414 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

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....

Jun 20 '07 #1
4 1490
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:DesignView.DataContext="{Binding
Source={VFW:MyDynamicResource VitoPatient},
Path=ParentObjects[Person__Patient]}">
.....

My Class:

<MarkupExtensionReturnType(GetType(Object)),
TypeConverter(GetType(DynamicResourceExtensionConv erter))_
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(serv iceProvider))
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

Jul 3 '07 #2
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(IProvide ValueTarget));
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 ...
}
}

Jul 4 '07 #3
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
Jul 4 '07 #4
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" <Ho********@discussions.microsoft.comwrote in message
news:47**********************************@microsof t.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

Jul 5 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thilaka | last post by:
Hi guys, Recently i read some articles on Longhorn & XAML. & From what i learnt the future for developing UIs lies in XAML. Does this mean that I've got to learn XAML as developing UIs for web...
13
by: Jeff | last post by:
How important is XAML? (or how important is it expected to become during the next 5 years?) Looking for informed opinions. Thanks!
7
by: GVN | last post by:
Hi All, I would like to write a .NET application which uses XAML. The following is my system's specification: Operating System : Windows XP ..NET Framework : 1.1
3
by: Brent | last post by:
OK i downloaded the new/addon framework 3 and downloaded the VS 2005 addon. I started with XAML. So far im like mehhhhhhhh. Anyone else have the same opinion? When i first heard about xaml i got...
2
by: azerty | last post by:
Hello I try to use xaml serializer framework to save in .xaml file my own hierarchical graph of object. The first step is done : I create my own file with something like this : <Root
0
by: =?Utf-8?B?WmlnZ3lTaG9ydA==?= | last post by:
I have a sample XAML file: <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <Button Name="button2" Height="23" Width="300" Margin="31,37,0,0" Click="doit">Hello...
6
by: star-italia | last post by:
Hi, Is it possible to include a XAML file into another XAML file? For example If i have - Window1.xaml - Window2.xaml and both have a treeview with a custom Style, can i describe the style...
1
by: DeanB | last post by:
Please excuse my ignorance here as I have not used WPF for long, but what is the statement that tells what the "local:" identifier is that allows a window event to call a function in a .cs file? ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.