|
Hai..
i am using a listbox where using mediaplayer as the list item. i am playing 5 videos simultaniously in 5 mediaplayer item, every video is a 10 sec video. i don't know how to loop all the videos.
Sample Code:
OpenFileDialog open = new OpenFileDialog();
open.Filter = AVI (*.avi)|*.avi;
open.ShowDialog();
MediaElement medi = new MediaElement();
medi.LoadedBehavior = MediaState.Play;
medi.UnloadedBehavior = MediaState.Stop;
medi.Source = new Uri(open.FileName);
medi.MediaEnded+=new RoutedEventHandler(medi_MediaEnded); ---> not working
menu.Items.Add(medi) ------> list box
|
|
|
|
|
Hi Everyone,
I have created a hot key screen scraper that works very well for windows application using win32 API. I need to do the same to a Silverlight Application that is hosted on a web. The goal is to allow reading data from the Silverlight web page automatically. I am able to get the handle to the browser window, but I'm not able to load the hidden data from the XAP object in the HTML page. I realize the XAP is just another zip file, but how do I get that loaded to a memory stream given the window handle for the browser?
Thanks a bunch in advance....
-Daniel
|
|
|
|
|
I was reading through posts such as this one on MSDN[^], and I was wondering why in MVVM, we constantly try to save 10 lines of code in the .xaml.cs class by adding 100 lines in the viewmodel or helper classes.
Can someone tell me the main benefit of taking such big hits in code size and readability to avoid putting code in the .xaml.cs file?
I would think that even if you do regular event handling in the .xaml.cs file, it still follows the textbook MVVM pattern (view knows viewmodel, viewmodel knows model, no other knowledge allowed).
|
|
|
|
|
I can see how keeping the business logic in the viewmodel makes sense, in which case doing normal event handling in the .xaml.cs file that calls a public method in the viewmodel would seem to suffice.
In the accepted answer in the MSDN thread I linked to, the answerer creates a static class (that the viewmodel is aware of) that specifically knows that the data is bound to a DataGrid (and not a Listview or a third-party data control). That sounds like a severe violation of the MVVM principle to me, in addition to being a pain in the butt to code and maintain.
However, I can't seem to find any examples of handling events that aren't the standard Command event (such as double-click, enter, or leave) elegantly without doing regular event handling in the xaml.cs file, which is frowned upon for some reason.
It feels like there is no real standard, and people are just juggling back and forth between competing bad practices and never really landing anywhere. I'm coding a bunch of WPF interfaces now, and I'd like me and my whole team to have a solid idea of what the best practice is.
|
|
|
|
|
Thanks; I'll read up on System.Windows.Interactivity.
|
|
|
|
|
You can hand over the xaml file to the styling / UI team while your developers can continue to code and build the code behind for that file.
|
|
|
|
|
The designers now can do their bit on the front end. The dev can do what they do best and then you end up with a good looking testable application (in a nutshell).
And, it looks cool!
|
|
|
|
|
Well, for someone who has started WPF stuff, MVVM, Commanding & Data Binding looks bit confusing because of the numerous articles on the Internet. You might have visit some of those articles and come to this point where you would like to know more about the MVVM. When I had started the WPF had the same issue that you currently facing.
The main advantages of the pure MVVM implementations are
1. Separation of concerns
2. Help out for Unit testing
3. Development can be carried out parallel
4. Tracing the changes/Impact and development is quite easy(this one is my favorite)
Implementing pure MVVM(not writing a single code of line communicating VM or M) is bit time consuming as you have to spend lot of time searching for the mechanism for communication e.g. double click events that you mentioned in your question above.
But believe me you will enjoy implementing it
To implement the Pure MVVM following points should be considered
1. Do not write single line of code communicating to the VM or Model
2. Though, View can contain the code lines related to GUI only. e.g. Adjusting some controls custom width/height on window size change, can go in main windows xaml.cs file as it has nothing to do with our VM and M. Its purely related to the View
3. If any controls needs to be referenced from the code behind, reference them from the App.xaml.cs file. App.xaml.cs, you can consider this as start up configuration. e.g. customizing the Title bar (showing the Title bar like Avast Antivirus check here) can go here.
4. Start the code from the App.xaml.cs file, configure your application here, like logging initialization, start up screen display, unhanded exception etc.
5. Inject the Model and View in the View model, this is best practices as view modes knows about view as well as model (know only at interfaces level)
6. Have a BaseVM class which will implement the INotifyPropertyChanged and derive your all Vm from this. This will help in eliminating repeated code
Hope this will help you get going
Happy Coding
|
|
|
|
|
The problem I have with MVVM is it is very difficult to implement multiple usercontrols on the same form. I like to have my ribbonbar as one user control, a sidepanel treeview control as another usercontrol, a tabcontrol as another usercontrol, and a statusbar of course as another usercontrol. I generally have a mainform that I place these on using <dockpanel> and <controls:ribbonbar dockpanel.dock="top"> etc. I've tried using caliburn micro to no avail as it will not display my controls even if I have no errors.
|
|
|
|
|
Dear friends...
Brief about my problem & Software:
I have developed a web based software using silverlight using c#. Its courier specific software. Here in one of the screen, I would get the data which tells me the count of consignments being delivered/not delivered.
This data, I would download as xls file.
PROBLEM : After downloading in the xls file, I want to click on one of the count (say delivered : 90). This should open up another screen where in displaying all the details of 90 consignments.
I just do not know how to achieve this through coding. Its as "PIVOT TABLE" in excel. where in user clicks and the data opens up in another sheet.
GUYS PLEASE HELP ME... If you need further help, please mail me : formulaone87@gmail(dot)com or post in this thread. I would revert you back...
Thank you
F1
modified 7-Jun-12 6:41am.
|
|
|
|
|
Your question shows such a dramatic lack of understanding that there is probably no way to help you until you have a deeper understanding of Silverlight/developing.
The only suggestion I can make is that you get a book and work through it from cover to cover, when you have gained some basic knowledge then try asking the question again, you won't need to!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ya I do underastand. I am a beginner... But you do understand my requirement.. Please help me the way it can be achieved...
I just want the way where in the data being downloaded from an application be opened as the way it works in excel file containing pivot data.
Your help is required very badly team.. Please help
|
|
|
|
|
When we copy the content of multiple cells (Rows X Columns) with border (Outer Border / All borders) from excel sheet and paste the copied content in to System.Windows.Controls.RichTextBox in the WPF window the content are pasted inside the text box with some of the borders are not present in the pasted content. We have also tried approach like converting the Clipboard text to XAML / HTML but no luck
sundherrajan
|
|
|
|
|
It seems to me that you are expecting a little too much from a RTB, I would expect it to handle wordprocessing formatting but to handle spreadsheet formatting I think is a stretch. Try pasting it into word and then copy/paste the results into the RTB!
Oh and REALLY take a look at your requirement for this!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dear All,
I am in need of Validation of my textboxes when i click save button in WPF.
I have tried this code :
app.xaml
-------------
<solidcolorbrush x:uid="SolidBrush" x:key="MySolidBrush" color="Red">
<solidcolorbrush x:uid="InnerBrush" x:key="MyInnerBrush" color="Red" opacity="0.05">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Text}" Value="">
<Setter Property="TextBox.BorderBrush" Value="{StaticResource MySolidBrush}" />
<Setter Property="TextBox.Background" Value="{StaticResource MyInnerBrush}"/>
<Setter Property="TextBox.ToolTip" Value="This Field is Mandatory"/>
</datatrigger>
</style.Triggers>
test.xaml
--------------
<textbox style="{StaticResource rfv}" margin="8,28,117,0" name="textBox1" height="22" verticalalignment="Top">
sumbit</Button>
The code is showing the message as tool tip when i move the cursor to textbox.
Since I am new to WPF, i need a code for Requiredfield validator as same as ASP.Net.
I have refered the Binding Rules (Validation Rules) concept also , but not know how to do.
All my need is when I click my button , It should show the error message to type something.
Please help me on this,Its urgent.
Regards,
SelvaKathir.C
|
|
|
|
|
Hi SelvaKathir,
I assume you have implemented the following things for triggering the Error.
1. Viewmodel implements IDataErrorInfo interface.
2. Set ValidationAttribute on each property which has to be validated or Use SelfValidation attribute on the class and override DoValidate.
3. Controls in Xaml are using bindings and ValidatesOnDataErrors=true,NotifyOnValidationError=true
4. Use a textblock to display the error by binding the error content of the target field. "<TextBlock Text="{Binding Validation.Errors)[0].ErrorContent, ElementName=YourTargetTextBox />"
5. Now how to display the error content on Save?
You have to set a boolean flag in ViewModel such as CanErrorDisplay and set it to true on Save.
6. Override the ErrorTemplate style and put conditional trigger on CanErrorDisplay and Validation.HasError to display Error.
This should work as per your requirement.
|
|
|
|
|
Hi All,
Am new to usage of WPF.Installed latest WPF toolkit and tried to make a window in Visual Studio 2008.
I am not able to drag and drop other WPF controls after the first drag and drop.
Explaining further, for ex. I have dropped a Label control onto window1.xaml and have configured it accordingly.
Next, I want another label or textbox or even grid on the window.But to my surprise,I was not able to drag and drop any other control.On one of the Microsoft forums, they told to delete the .tbd files from the AppData directory and reset the toolbox.Did all these stuffs but no success as of yet.
Please assist.
Anurag
A Curious Newbie...
|
|
|
|
|
Go to the Visual Studio command prompt and try to reset the environment by using devenv /resetsettings .
You will however loose all VS settings that you may have created as customized settings.
|
|
|
|
|
hii..got around the problem by upgrading the .net framework 3.5 to SP1..now i am able to drag and drop other controls...however, a new problem persists..I am not able to customize the toolbox though..i right clicked on the toolbox area and clicked on choose items..then a dialog box appears with various menus..clicked on 'WPF components'..chose the controls which i needed and then clicked on OK..but to my surprise the controls were not added...tried it again 2-3 times but to no success..restarted VS again and repeated the whole procedure but couldn't do it...Please help..
Anurag
A curious newbie
|
|
|
|
|
Please let me be more percise with the problems that are occuring. What I have are two list boxes and add/remove buttons between them. Now what I do is have a collect for the ALL ITEMS and a collection for the SELECTED ITEMS. What is happening is that when the user selects an item from the ALL ITEMS list and clicks the add button it does not show up in the SELECTED ITEMS list until the user clicks the add button one more time. What I am doing is iterating through the allItems collection and checking for the item in the selectedItems list. Now, if the item that was selected during the add button click event is not in the selectedItems list the I use the .Add method to add it to the SELECTED ITEMS list box. After the first item makes it over to the SELECTED ITEMS then the Add/Remove buttons work just fine. What we did to test this and determine that it was a Silverlight 5.1 client issue is switch out, starting at version 4.0 then 5.0 then finally 5.1 clients and everything worked fine for 4.0 and 5.0 but when 5.1 was loaded on the client it start to experence the problem. If anyone can provide some insite that would be great!
Thanks,
Steve Holdorf
|
|
|
|
|
Can you post your code && XAML please..I don't think Silverlight client has to do anything with your issue.
Cheers!
Vinod
Vinod Kumar Prajapati
Software Engineer
EBC Publishing Pvt. Ltd.
|
|
|
|
|
Hi, I'd like to do a simple game with a little amount of user interation (mouse and keypad) and I really don't know which can be the best approach for the implementation, considering the issue of animations that hav to be implemented.
Wpf could be the "correct" option or also html5+javascript can be ok ?
Thanks.
Best regards, Stefano.
|
|
|
|
|
Use WPF for a desktop application.
Web browser - use Silverlight or html5 (based on what you are comfortable with).
|
|
|
|
|
Hi friends,
I have Observable collection list of prefix which is binded with the combobox itemsource prperty in VIEW.
SelectedPrefix Property which is binded with selectedValue property.
Now when I change the List and remove some items the SelectedPrefix is not updated.
For Example I have selected Dr in combobox. The SelectedPrefix is also updated with Dr
Now if I remove the Dr from the List SelectedPrefix still contain Dr. it should be null or empty.
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
Are you using INotifyPropertyChanged in your collection?
|
|
|
|