|
Prajeesh wrote: StartPoint = Args.GetPosition(PhotoBox);
In the MoveDown event, what is PhotoBox? shouldn't it be DrawingCanvas ?
I did the same thing you are doing, on the MouseMove and MouseLeftButtonDown event of the Canvas, and I never got any extra lines.
|
|
|
|
|
|
private void OnMouseMove(object Sender, MouseEventArgs Args)
{
if (Args.LeftButton == MouseButtonState.Pressed)
{
EndPoint = Args.GetPosition(DrawingCanvas);
DrawLine(StartPoint, EndPoint, DrawingCanvas);
//do not reset the startpoint
//StartPoint = EndPoint;
}
}
And in your DrawLine method, delete the old line before adding the new line.
|
|
|
|
|
|
Searching for the control and removing it from the Children collection.
Something like this,
Line previousLine = null;
foreach (UIElement child in TargetCanvas.Children )
{
if( child is Line)
{
previousLine = child as Line;
break;
}
}
if (null != previousLine)
{
TargetCanvas.Children.Remove(previousLine);
}
please update it to fit your needs.
|
|
|
|
|
|
Yes, I hope you can build ahead from the help you have been provided. What you could do is generate a new line name everytime you start drawing and use that line name in the MoveMouse for adding the new line and also for deleting the existing line.
|
|
|
|
|
I'd leave it if I were you. It looks like he wants you to give him the complete code.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys
|
|
|
|
|
I reminded him about the advise you had provided him few posts ago, but he doesn't seem to pay any heed to it.
|
|
|
|
|
I have a WPF application (client/server). i had created .exe file. when i install it on my client box it will install all the the dll's in the program files/manufactuere/ productname folder.It will install dll's of different languages also( spanish dll's in ES folder, portugese dll's in pt folder in program files/manufactuere/ productname)
What i need is when client is installing it i need to give him an option to select the language. based on the language it should install the concerning dll's in the client box.
Setup project is not giving any option to select language.
Please help thanks.
i used this article.
http://www.eggheadcafe.com/conversation.aspx?messageid=32327069&threadid=32327069
i did whole steps accordingly but when i try to install setupEn.msi its displaying in chinese.
i was wondering i am still not getting options for selecting the language.
|
|
|
|
|
Have you read the entire thread ? Because ahead in the thread the OP got the same issue and the person has provided a clarification for the same.
|
|
|
|
|
psdeepu wrote: Please help thanks
How many times are you planning on posting the same question?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Hi,
let's have a ListBox, bind to a observable Collection within a class instance in Xaml:
<ListBox ItemsSource="{Binding Path=MyInstance.MyCollection}"/>
Everything works as expected until the MyCollection-reference gets changed to another Instance of the Collection or even the Object-reference which contains the Collection gets changed to another Instance, like so:
Public WithEvents AnotherCollection As New ObservableCollection(Of Something)
MyInstance.MyCollection = AnotherCollection
or even
MyInstance = New MyClass
From this point on, the binding seems to be broken. Till now I worked around this by clearing the list and adding the items one by one.
Am I missing a better solution for this?
thank you,
dartrax
www.dartrax.de
|
|
|
|
|
Is your binding Two-way ? If not, try setting it Two-way and see if things work.
If not, try rebinding to the ItemsSource again or see if this[^] helps
|
|
|
|
|
Use the System.ComponentModel.INotifyPropertyChanged interface.
Let class A
class A : INotifyPropertyChanged
{
List<string> _list;
public List<string> List
{
get
{
return _list;
}
set
{
_list = value;
NotifyPropertyChanged("List");
}
}
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
a window
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
<ListBox ItemsSource="{Binding List}" />
<Button Click="Button_Click" Content="Change reference" />
</StackPanel>
</Window>
with a code behind containing
public partial class Window1 : Window
{
A _a;
public Window1()
{
InitializeComponent();
_a = new A();
_a.List = new List<string>
{
"a",
"b",
"c",
"d",
"e",
};
this.DataContext = _a;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
_a.List = new List<string>()
{
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
};
}
}
Eslam Afifi
|
|
|
|
|
I got curious and tried your example, as it is. But it did not work for me I had to put this statement at the end of button click handler to make it work,
mylistbox.ItemsSource = _a.List;
I presume you have this working on your machine ?
|
|
|
|
|
It works without resetting the ItemsSource. I uploaded it here[^].
Eslam Afifi
|
|
|
|
|
It definitely works in your app. It just doesn't work in mine. ill take a look at it later. Mine is little bit crappy though. Thanks
|
|
|
|
|
You're welcome
Eslam Afifi
|
|
|
|
|
Thank you, Eslam, this works absolutely great!!!
(Mode=TwoWay seems not to work)
dartrax
www.dartrax.de
|
|
|
|
|
|
Hi,
I am new to WPF, just seeking some help.
I wanted to create a user control at which it is like an augmented panel(lets call it userpanel). There is a panel where content can be placed, and some buttons on top of the panel to do something.
What do i need to do to make what ever content i put into the usrpanel.content to go into the panel of the user control?
Right now if i insert some words into the Content of the usrpanel, the whole control blanks out with the text i punch in.
thank you
|
|
|
|
|
Use a layout control such as a Grid , StackPanel or Canvas to act as a container of your sub-controls.
/ravi
|
|
|
|
|
How can i do that? Do you have any example?
|
|
|
|
|
If I have two user controls, each with a dependency property, and both those controls are thrown into a grid, how could I bind the results of one of those properties to the other?
In short:
Control2.Customer = Control1.SelectedCustomer;
Where Customer and SelectedCustomer are the two respective DP's.
I've tried:
<local:Control1 Grid.Row="0" x:Name="customerSelector" />
<local:Control2 Grid.Row="1" Customer="{Binding ElementName=customerSelector, Path=SelectedCustomer}" />
The binding doesn't appear to do anything. A breakpoint on the setter of the Customer property never gets hit.
Any thoughts?
-Mike.
|
|
|
|