data binding a collection onto a canvas

data binding a collection onto a canvas

Post by Steve Mill » Mon, 24 Mar 2008 10:36:41


I have an ObservableCollection of objects that encode a reference to
an image with left, top, width, and height. I want to data bind them
onto a Canvas in a WPF Window. What I've tried uses:

<DataTemplate x:Key="ImageTemplate">
<Image
Source="{Binding Path=Key, Converter={StaticResource
magePathConverter}}"
Width="{Binding Path=Width}"
Height="{Binding Path=Height}"

<Canvas.Left><Binding Path=Left" /> </Canvas.Left>
<Canvas.Top><Binding Path=Top" /> </Canvas.Top>

</Image>
</DataTemplate>


<ListBox Name="Images"
ItemTemplate="{StaticResource ImageTemplate}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Canvas />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>


The images show up on the Canvas just fine, EXCEPT that the left and
top all come out == 0.0. The image file is picked up, the width and
height are fine, but not left and top.


All suggestions welcome.


- Steve
 
 
 

1. Referencing data set B in data step A's DO loop

2. Copy all data from a:Class A's fields to the namesake fields of b:Class B.

I have two class with nearly exactly same attributes, the only difference is
class B's property setter does some argument checking.

[Serializable]
class A
{
private string a;

public string AA
{
get { return a; }
set { a = value; }
}
}

[Serializable]
class B
{
private string a;

public string AA
{
get { return a; }
set
{
if (string.IsNullOrEmpty(value))
{
throw new ApplicationException();
}
a = value;
}
}
}

I want to do the following:
A a = new A();
a.AA = "123123";
B b = (B)a; -- Copy a's attribute values to b.
Please tell me how to implement a generic function to support copying
namesake fields from one class instance to another even when they belongs to
different class type.

Thanks.

zlf

3. binding canvas item versus binding canvas widget

4. Printing report b after report a prints using report a's variables

5. Why does Form-A's instance fire Form-B's event??

6. using "if" but omitting the #n/a's

7. equation that will filter out #N/A's

8. "Matching" column A's values in column B

9. Formula's with #N/A's

10. How do I only get valid "answers" in a VLOOKUP function (no #N/A's

11. 'Send As' messages stay in User A's sent folder.

12. Scottie A's Hall of Flame

13. CAnnot type lowercAse 'A's Anymore (solved!)

14. lookup only finds #n/a's

15. Try Again / VLOOKUP without N/A's