473,395 Members | 1,458 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,395 software developers and data experts.

RE: WPF: Use MultiBinding to bind polyline point to a thumb

Hi George,

Thank you for posting!

This is a quick note to let you know that I am doing research on this issue
and will get back to you ASAP.

I appreciate your patience!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 3 '08 #1
1 5312
Thanks Chris for your wonderful reply!

Hi George,

As Chris has points out, the reason why the first point of the polyline is
not actually bound to the thumb is that when a dependency property of a
binding target is bound to a data source, the corresponding CLR property
won't be called when data binding retrieves data from data source to
binding target.

In your case, the Set property procedure of the FirstPoint property will
never be called when you drag the thumb.

The workaround that Chris provided is correct.
Also, any ideas how I could revise this to bind to any other point of the
polyline.

I suggest that you add a static field in the ArrowPolyline class for the
index of the bound point and add a method to set this value. Then you can
use this static field in the PropertyChangedCallback handler of the
FirstPointProperty dependency property (since we'll bind any point of the
polyline now, you may rename the FirstPointProperty to BoundPointProperty).
For example:

public class ArrowPolyline : ArrowLineBase
{
private static int boundPointIndex = -1;
public int BoundPointIndex
{
get { return boundPointIndex; }
}

public bool BindToPoint(int index, ref Point pt)
{
if (index >= 0 && index < Points.Count)
{
boundPointIndex = index;
pt = Points[index];
return true;
}
else
{
return false;
}
}

public static readonly DependencyProperty BoundPointProperty =
DependencyProperty.Register("FirstPoint", typeof(Point),
typeof(ArrowPolyline),
new FrameworkPropertyMetadata(new Point(0, 0),
FrameworkPropertyMetadataOptions.AffectsMeasure,
(DependencyObject sender,
DependencyPropertyChangedEventArgs e) =>
{
ArrowPolyline polyline = sender as
ArrowPolyline;
if (boundPointIndex >= 0 && boundPointIndex <
polyline.Points.Count)
{
polyline.Points[boundPointIndex] =
polyline.BoundPoint;
}
}));

public Point BoundPoint
{
set { SetValue(BoundPointProperty, value); }
get { return (Point)GetValue(BoundPointProperty); }
}
*
}

Add a TextBox on the Window1 and add the following code in the code of the
Window1:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ArrowPolyline ap = AddArrowPolyline();
Thumb thm = AddThumb();
BindPolylineToThumb(thm, ap);
}

// input the index of the point you want to bind in the TextBox and press
the Button
private void button1_Click(object sender, RoutedEventArgs e)
{
Point pt = new Point ();
if (ap.BindToPoint(Convert.ToInt32(this.textBox1.Text ), ref pt))
{
Canvas.SetLeft(this.myThumb, pt.X - this.myThumb.Width/2);
Canvas.SetTop(this.myThumb, pt.Y-this.myThumb.Height /2);
}
}

Run the application and input the index of the point you want to bind in
the TextBox and press the Button. You should see the thumb moves to the
location of the specified point and the point moves with the thumb when you
drag the thumb.

I will send the modified sample project to your email box. Please run it on
your machine to see if there's any problem.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jul 4 '08 #2

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

Similar topics

6
by: moondaddy | last post by:
I'm writing a windows app in WPF and want to change the shape of a thumb to an ellipse. Is this possible? also, the edges of the thumb are beveled. Is it possible to change this to a flat look...
2
by: moondaddy | last post by:
I'm creating a sample project where I will adorn a Polyline with thumbs so I can resize it by dragging its ends (and points) around. This is similar to some projects I've posted using a...
3
by: moondaddy | last post by:
I have a windows WPF sample project which is starting to work pretty good. I can drag shapes and lines, and connect a straight line to any place on a custom rectangle shape's boarder. Now I have a...
0
by: =?Utf-8?B?YWxleF9jYXJvMQ==?= | last post by:
Hi, I would like to use a multibinding to determine the fill value of my rectangle style. <Style x:Key="StyleRect" TargetType="{x:Type Rectangle}"> <Setter Property="Fill"> <Setter.Value>...
10
by: moondaddy | last post by:
Hi, I have 3 tiny content controls and each has a Path in it to draw some lines. These need to be very small and I'm having trouble making the lines clear. the lines have a stroke thickness of "1",...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
1
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample project and built it on my machine. When I start the application and click the Button on the window, I get an InvalidCastException on the line of code...
0
by: Chris Jobson | last post by:
>I have a sample similar to a previous post where I was binding a line end Not sure if I'm right, but I think the problem is that the data binding doesn't go through the property wrapper, but...
6
by: raylopez99 | last post by:
This language C# is more primitive than I thought. I just found out that C#2.0 does not support polyline (see below), a very useful feature for connecting points with a line automatically. Only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.