|
assuming your listboxitem is of type string you should do:
myMediaElement.Source = new Uri(myListBox.SelectedItem.ToString());
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Don't understand the concept of strings yet, so i highly doubt it is one.
I'll try this nonetheless
Ok Modified:
System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="Bleach Player"
StackTrace:
at WpfApplication1.Window1.ListBoxItem_Selected(Object sender, RoutedEventArgs e) in C:\Documents and Settings\Nick\My Documents\Visual Studio 2008\Projects\Bleach Player\Bleach Player\Window1.xaml.cs:line 61
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.ListBoxItem.OnSelected(RoutedEventArgs e)
at System.Windows.Controls.ListBoxItem.OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Markup.BamlRecordReader.SetDependencyValueCore(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)
at System.Windows.Markup.BamlRecordReader.SetDependencyValue(DependencyObject dependencyObject, DependencyProperty dependencyProperty, Object value)
at System.Windows.Markup.BamlRecordReader.ReadPropertyCustomRecord(BamlPropertyCustomRecord bamlPropertyRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
InnerException:
modified on Friday, June 6, 2008 7:25 PM
|
|
|
|
|
could you please post the code where you are adding the source of the mp3 file to the listbox?
also if there isn't an item selected then the "SelectedItem" property will be null and in return throw the exception that you posted
EDIT:
this is how i would do it.
I'm not sure how your getting the file path, but if the filepath is a string then you would add it to the listbox like this:
string myFilePath = @"C:\myMp3\Soundgarden - Some Song.mp3";
myListBox.Items.Add(myFilePath);
then i would hook the ListBox.MouseDoubleClick. This will fire when a user doubleclicks on a song
private void myListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (myListBox.SelectedItems.Count > 0)
{
string mySelectedFilePath = myListBox.SelectedItem.ToString();
myMediaElement.Source = new Uri(mySelectedFilePath);
}
}
Don't be overcome by evil, but overcome evil with good
modified on Friday, June 6, 2008 8:06 PM
|
|
|
|
|
Still not getting this to work out right, i figured out I'm missing the mySelectedFilePath . And if i leave as is, no song plays/it adds the same thing into the list over and over and over (if you keep selecting it)
Trying to switch things around to see if it works but still has been giving the same errors as before.
And i can't show you the code to what i had before, i switched it to see if it would work as you said you would do. Accidentally saved after changes (habit)
|
|
|
|
|
Hi Nick,
Its going to be really hard for anyone to help you further unless you post the code you *are* using. A string is CHARACTER based type ...
1 = numeric
"1" = string
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
C# Beginner Nick wrote: Still not getting this to work out right, i figured out I'm missing the mySelectedFilePath. And if i leave as is, no song plays/it adds the same thing into the list over and over and over (if you keep selecting it)
You must be adding adding the songs to the listbox in the wrong place.
C# Beginner Nick wrote: Trying to switch things around to see if it works but still has been giving the same errors as before.
Instead of switching things around to "try" to get it to work, you really need to read a good book. My Favorites are:
Pro C# 2008 and the .NET 3.5 Platform, Fourth Edition[^] - This helps understand C#
Pro WPF[^] - This is geared more for wpf.
C# Beginner Nick wrote: And i can't show you the code to what i had before, i switched it to see if it would work as you said you would do. Accidentally saved after changes (habit)
Without any code, i have no clue on what your doing. So its real hard to help you further
|
|
|
|
|
Alright, I've been trying to save money for some books, but money nowadays goes by to fast.
Thanks,
And to the other guy, i changed my code to what teejayem said he would try, so what his code is, is what my code was before i tried to start over.
|
|
|
|
|
I've made a complete solution for you ... have a look at this to see how to do what you want.
PlayMediaElement from Listbox[^]
Change the directory in the source code to somewhere you know you have .avi files and then build it and run it ...
alternatively you could change the extension from "*.avi" to "*.mp3"
You've not picked a simple task to start with really. MediaElement is a tempramental beast!!
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I usually hate starting off easy, medium is fine.
Thanks, i'll take a look at it.
|
|
|
|
|
Hi,
In my project, there is a requirement to consume STORM control into XAML page. Is XAML support any third party custom control (Other than WPF control)? If yes, how to consume it?
Greatly appreciate any help..
Thanks in advance
Best Regards,
Anand.
|
|
|
|
|
Have a look into the WPF WindowsFormsHost control ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi.
I am a student and working in dotnet3.5. I want to customize WPF forms for PDA's. I read many articles in which PDA's Resolution problem and its screen attributes are discussed. I want to run the Forms both Desktop and web based forms on PDA.
Second issue is related to WCF as i want ro build a wireless intranet in which 5-10 PDA's can communicate with the Application Server.
Any idea, Links,Articles would be very helpful for me.
Thanks.
|
|
|
|
|
Hey guys,
I have been developing some custom WPF UserControl's (System.Windows.Controls.UserControl -- .dll) in WPF/C#. I was wondering how I could use these custom controls inside of a webpage? Can anyone provide any examples of WPF ActiveX embedding code using HTML/JavaScript etc?
I greatly appreciate any help.
David.
|
|
|
|
|
Great question, I have been wondering this for some time but haven't gotten around to trying it. I can't find any examples online for this, but I'm sure a WPF MediaElement or other control can be embedded inside a webpage, I'm just not sure how.
madness ? this.isSparta = true : this.isSparta = false;
modified on Friday, June 6, 2008 4:47 PM
|
|
|
|
|
In the WPF window, i have a check box that i want to be checked and make the program stay up top of all others.
this.TopMost();
But i keep getting this error
Error 1 Non-invocable member 'System.Windows.Window.Topmost' cannot be used like a method. C:\Documents and Settings\Nick\My Documents\Visual Studio 2008\Projects\Bleach Player\Bleach Player\Window1.xaml.cs 36 18 Bleach Player<br />
I've tried to throw an exception and that just threw me down a long road of errors.
Anyone explain why i can't do this or use this:
<br />
if (Change.Checked)<br />
{ FormBorderStyle = FormBorderStyle.None; }<br />
else <br />
{ FormBorderStyle = FormBorderStyle.SizableToolWindow; }
To change the window border frame?
Btw, i know this is in the WPF forum, not C# as the codes above are. Before you start flaming i understand this but i am creating a WPF window not a C# program.
|
|
|
|
|
TopMost is a propterty, so try:
this.TopMost = true;
I'm assuming Change is a CheckBox, and in that case you can't do if (Change.Checked) because Checked is an event. Use IsChecked which is of type bool? (? means it is nullable as in System.Nullable):
if ((bool)Change.IsChecked)
I don't know where FormBorderStyle came from. If you're using a System.Windows.Window use
WindowStyle = WindowStyle.None;
and
WindowStyle = WindowStyle.ToolWindow;
|
|
|
|
|
Thanks, these worked, had to change TopMost to Topmost though.
modified on Friday, June 6, 2008 7:06 AM
|
|
|
|
|
Hi all,
I am trying to build a game based on the WPF and WCF. Client and server work fine on my machine(Vista 64), they are connected successful. But when I am trying to run server on the LAN machine(WinXp) and client on my machine(Vista 64), after calling service metod from client application I get exception:
"Fail agreement of mode security SOAP from "http://192.168.0.55:8080/Pf\" for object "http://192.168.0.55:8080/Pf\"."????
Help please to resolve the problem.
|
|
|
|
|
Have you configured the security on your bindings yet? I'd try turning the security off on both client and server bindings add see if that allows calls through.
Replace the WSHttpBinding with the type of binding you're using and set the security mode to None.
WSHttpBinding binding = new WSHttpBinding(SecurityMode.None);
or if the binding is in a config file:
<security mode="None"/>
If that works then your problem is with security.
|
|
|
|
|
Brian thanks for help.
Here is the cut of my server app.config file:
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPref">
<security mode="None"/>
</binding>
</wsDualHttpBinding>
</bindings>
Here is is the cut of my client app.config file:
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPref" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
If I change
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
to
<security mode="None">
</security>
It fails with something like this:
"Operation of opening doesn't complete in the course of defined period 00:01:00"
even if the server and the client are running on my machine.
|
|
|
|
|
It may need the message element (both files):
<security mode="None">
<message clientCredentialType="None" negotiateServiceCredential="false"
algorithmSuite="Default" />
</security>
I did a quick test with the binding. The server on vista64 and client on XP. After turning off the firewalls it worked. The only difference is I didn't use a config file, just hard coded everything for the test. If you'd like I can post it.
|
|
|
|
|
Ok, I'll try to do this.
If it's possibly, please send me to losqut@yandex.ru
|
|
|
|
|
Hi All!
I found Silverlight User Control Template is missing when i create a new Asp.Net project.
Does Anybody know what to do to add that template to Visual Studio 2008
Thanks and Regards
Vijay. R
|
|
|
|
|
Please take a look at my reply in your previous message http://www.codeproject.com/script/Forums/View.aspx?fid=1004257&msg=2584440[^]
In Silverlight 2 beta1, all default templates for all user controls are stored in generic.xaml. If you are creating custom database which is inherited from build-in control, you will need to use those styles from generic.xaml unless you create all required template by yourself.
|
|
|
|
|
Hi Friends,
I am unable to create docking control in silver light 2.0.My requirement is I am using one menu control in silver light,I want to apply docking to that control.So I am unable to do that,can u pleaes help me in this.
Regards
Kishore
|
|
|
|