|
Listen PartSocket newsock = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
IPEndPoint iep = new IPEndPoint( IPAddress.Any, 2091 );
newsock.Bind( iep );
newsock.Listen( 5 );
newsock.BeginAccept( new AsyncCallback( AcceptConn ), newsock );
void AcceptConn( IAsyncResult iar )
{
Socket oldserver = ( Socket )iar.AsyncState;
client = oldserver.EndAccept( iar );
Thread receiver = new Thread( new ThreadStart( ReceiveData ) );
receiver.Start();
}
void ReceiveData()
{
int recv;
string stringData;
while( true )
{
recv = client.Receive( data );
stringData = Encoding.ASCII.GetString( data, 0, recv );
if( stringData == "bye" )
break;
}
stringData = "bye";
byte[] message = Encoding.ASCII.GetBytes( stringData );
client.Send( message );
client.Close();
return;
}
Connection
client = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp );
IPEndPoint iep = new IPEndPoint( IPAddress.Parse( "127.10.27.61" ), 2091 );
client.BeginConnect( iep, new AsyncCallback( Connected ), client );
void Connected( IAsyncResult iar )
{
client.EndConnect( iar );
Thread receiver = new Thread( new ThreadStart( ReceiveData ) );
receiver.Start();
}
My code is like thisduring the connection part error happends,May be due to 2 threads,how can i solve the same
|
|
|
|
|
Good afternoon.
I cant seem to get a combobox to select a value using Binding. I have a small example that re-creates the issue, I want the combo to have selected Yellow (_colour is set to that on creation) when it first loads. Hope that makes sense
Code is below, just window1 and a class called ViewModel. TIA for any help
Window1.xaml
<window x:class="ComboBoxTest.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<grid>
<combobox margin="92,122,66,116">
ItemsSource="{Binding Path=Colours}"
DisplayMemberPath="Description"
SelectedItem="{Binding Path=SelectedColour, Mode=TwoWay}"
Grid.Column="1"
Grid.Row="8"
IsSynchronizedWithCurrentItem="True"
/>
</combobox></grid>
</window>
Window1.xaml.cs
using System.Windows;
namespace ComboBoxTest
{
public partial class Window1 : Window
{
public Window1()
{
this.DataContext = new ViewModel();
InitializeComponent();
}
}
}
ViewModel.cs
using System;
using System.Collections.Generic;
using System.Windows;
namespace ComboBoxTest
{
public class Colour : IComparable
{
public string Description { get; set; }
#region IComparable Members
public int CompareTo(object obj)
{
return string.Compare(((Colour) obj).Description, this.Description);
}
#endregion
}
public class ViewModel : DependencyObject
{
public List<colour> Colours
{
get
{
List<colour> retval = new List<colour>();
retval.Add(new Colour { Description = "Blue" });
retval.Add(new Colour { Description = "Green" });
retval.Add(new Colour { Description = "White" });
retval.Add(new Colour { Description = "Yellow" });
retval.Add(new Colour { Description = "Red" });
retval.Add(new Colour { Description = "Silver" });
return retval;
}
}
private Colour _colour = new Colour { Description = "Yellow" };
public Colour SelectedColour
{
get { return _colour; }
set { _colour = value; }
}
public static readonly DependencyProperty SelectedColourProperty =
DependencyProperty.Register("SelectedColour", typeof(Colour), typeof(ViewModel));
}
}
|
|
|
|
|
|
Thanks for your reply, this was a test project and you are right i did not have the Selected Colour correct, i have changed it and it still does not work, so will look at INotifyPropertyChanged, and let you know.
Mark
|
|
|
|
|
Cant get that working either, If anybody would be able to convert my sample app, i would be greatful
|
|
|
|
|
Does it work if you implement your Colour class something like this?
public class Colour
{
public string Description { get; set; }
public override bool Equals(object obj)
{
return this.Description == (obj as Colour).Description;
}
public override int GetHashCode()
{
return base.GetHashCode() ^ this.Description.GetHashCode();
}
}
...and your SelectedColour dependency property:
public static DependencyProperty SelectedColourProperty =
DependencyProperty.Register("SelectedColour", typeof(Colour), typeof(ViewModel));
public Colour SelectedColour
{
get { return (Colour)GetValue(SelectedColourProperty); }
set { SetValue(SelectedColourProperty, value); }
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Many thanks for your reply.
That still does not do what i want, i am starting to think that i am going about this the wrong way
Put simply what i need is a combobox with a datasource of list of my objects (all the same type). Then when the form loads i want the combobox to have preselected an object of my choice (what ever was saved in xml/db)
I am new to wpf and the mvvm pattern, and this is getting a bit frustrating!!
ps for info i changed the colour class to the following as the other throw an exception
public class Colour
{
public string Description { get; set; }
public override bool Equals(object obj)
{
if(obj.GetType()== typeof(Colour))
return this.Description == ((Colour) obj).Description;
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode() ^ this.Description.GetHashCode();
}
}
|
|
|
|
|
I want creat a Analog Clock in WPF. Help me! Please, Thanks so much.
|
|
|
|
|
A simple search would have found this[^].
"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 | Onyx
|
|
|
|
|
Hi,
I am developing one application using silverlight and .Net.There are some videos to watch.There are some features like rotate,scaling video using silverlight.Now I want to develop feature Throw videos using silverlight like in the following site.
http://www.etsy.com/color.php?ref=fp_nav_colors.If u open that link there are some bubbles,if you click those bubles you will find some images.In that we can throw those images to anywhere. I want to develop that feature using silverlight in my site.Can please anyone help me how to do that task using silverlight and .Net.
Thanks in advance
Pavani
|
|
|
|
|
pavanip wrote: Can please anyone help me how to do that task using silverlight and .Net.
you can consider hiring some Silverlight consultants to get it done.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
I have a MFC dll, which one inherit the CFormView and I add a textbox in that FormView. I want to load that dll from WPF and display it in the window as a control. If anyone have an idea about this, please help me.
|
|
|
|
|
Why would you want to do this? It's easy enough (i.e. trivial) to do exactly this in WPF, so why would you want to go to all the trouble of adding in an external DLL to do this? BTW - I'm not the one who voted 1.
"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 | Onyx
|
|
|
|
|
Hi All,
I've just started looking into this in relation to an app I've made. It's a fairly simple app, most of the pages just have a handful of controls (the main one being Infragistics Grid) spread over a few pages. The app has been designed and implemented using Prism (Composite).
When I first launch the app I'm seeing nearly 60Mb of ram in use before the application has opened any data files. I'm currently going through the WPF Performance Suite tools to see what this shows up. Any tips would be good!
Anyone else experiencing anything like this with their apps?
|
|
|
|
|
It is normal. See comments here.[^]
|
|
|
|
|
Interesting comments. I had bookmarked that article but it had slipped my mind, thanks for pointing me to it.
|
|
|
|
|
I'm stuck (as usual).
A have a user control with 6 textboxes. But to make it easier, I'm trying to break down the problem a bit and lets say there is one textbox.
USERCONTROL1.XAML:CS
public partial class AttenuationBox : UserControl
{
private String justAtest;
public String ATest { get { return justATest; } set { ...
public String LowChRx
{
get { return tbLowChRX.Text; }
set { tbLowChRX.Text = value; }
}
...
}
USERCONTROL1.XAML
<textbox name="tbLowChRX" text="{Binding Path=ATest}"></textbox>
Now I want tbLowChRX to be bound to justAtest. But just can't get it to work. Must be something I have missed in Source or Path or...
modified on Sunday, April 19, 2009 12:49 PM
|
|
|
|
|
You will need to make sure the source is right on the binding.
Here's a simple example of one way to do it:
WPF: Binding to Properties in your UserControl or Window[^]
I'm not sure why you'd want to bind directly to the field, nor do I think
you can, but you should be able to bind to the ATest property. Of course, for
change notifications when the property is updated, you may want to make that a
dependency property.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh, my fault, the intention was to bind to the property
|
|
|
|
|
Then that example at the link works...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello Friends I am getting these errors in my wpf application. Any help would be appreciated as I am totally new to this environment/
Error 1 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'AddNew' and no extension method 'AddNew' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 77 29 WpfMasterDetail_CS
Error 2 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'CommitNew' and no extension method 'CommitNew' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 78 29 WpfMasterDetail_CS
Error 3 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'RemoveAt' and no extension method 'RemoveAt' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 89 29 WpfMasterDetail_CS
Error 4 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'AddNew' and no extension method 'AddNew' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 121 29 WpfMasterDetail_CS
Error 5 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'CommitNew' and no extension method 'CommitNew' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 122 29 WpfMasterDetail_CS
Error 6 'System.Windows.Data.BindingListCollectionView' does not contain a definition for 'RemoveAt' and no extension method 'RemoveAt' accepting a first argument of type 'System.Windows.Data.BindingListCollectionView' could be found (are you missing a using directive or an assembly reference?) D:\Other\Personal\WPF\Tutorial\Windows Client\Zip Files\Wpf-Data-MasterDetail_CS\WpfMasterDetail_CS\WpfMasterDetail_CS\Window1.xaml.cs 129 33 WpfMasterDetail_CS
|
|
|
|
|
I have a MFC dll, which one inherit the CFormView and I add a textbox in that FormView. I want to load that dll from WPF and display it in the window as a control. If anyone have an idea about this, please help me.
|
|
|
|
|
|
I am implementing a scenario where I'm loading 3 or 4 views inside the tabcontrol. My tabcontrol region is defined using the TabControlRegionAdapter. I am able to load these views into this region without any problems. However, I am unable to control the layout of the tab control once these views get loaded. Thus my views scroll out of my page (so to speak) and are not visible on the screen. I understand that the tab control uses ItemsControl to display its content. I tried defining the layout using ItemsTemplate but even that seemed to have no effect.
How can I control the layout of the content inside a tab so that all my views can be completely visible on the screen? Also, is there a solution such that as I resize my browser, this content too gets automatically resized? In my present scenario, as I resize my window, more and more of my view content gets clipped.
Thanks for any help or guidance in advance.
|
|
|
|
|
I am working in WPF. Normally on lost focus of textbox , text are unselected. But if I set the value e.handled = true on lostfocus event handler, unselection doesn't happen. I need to set e.handled = true to prevent the event from bubbling up. Note: I am not stopping from lostfocus being triggered. LostFocus takes place, its just that, automatic unselection doesn't happen and I want the unselection to take place.
Private Sub MyTextBox_LostFocus(ByVal sender As Object, ByVal e As RoutedEventArgs)
e.Handled = True
End Sub
|
|
|
|