|
Hi,
i tried to implment the MVP Pattern in silverlight 2 but i found some problemes.
First i create a several project:
- Silverlight project (views: xaml pages )
- Presenter project (presenters and viewInterfaces)
- WebServices project
- Model project (buisness object)
When i tried reference my presenter project to silverlight project ( the view implement the view interface) Visuel studio 2008 poste this error message:
"Silverlight projects can only be referenced by other Silverlight projects"
this is understandable for deployed code but what is the solution for this, how can i add this reference.
thanks for your help
|
|
|
|
|
Hello,
almora007 wrote: When i tried reference my presenter project to silverlight project ( the view implement the view interface) Visuel studio 2008 poste this error message:
"Silverlight projects can only be referenced by other Silverlight projects"
this is understandable for deployed code but what is the solution for this, how can i add this reference.
You can't reference other .NET dlls except Silverlight Class Library only. When you create the presenter project, you need to choose Silverlight Class Library template.
almora007 wrote: - WebServices project
Another thing that you should know even you didn't ask..
If you are using Visual Studio Development Server, you can't use different webservice project because of cross-domain issue. You will need to add the web service item to ASP.NET project....
|
|
|
|
|
Can you please advise on checkbox in a combobox and binding, where itemsource is a collection.
|
|
|
|
|
Can you please provide a more detail of what you are trying to accomplish?
This article I wrote covers using a CheckBox inside a ListBox so the binding will be similar in that you'll use a Data Template to accomplish what you need.
http://www.codeproject.com/KB/WPF/WPFProblemSolving.aspx[^]
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I have a simple question that I hope someone can help me with.
All of the Wpf examples that I have seen which bind a ListView to a collection do so by declaring the collection as static. How do you accomplish this with a non-static collection?
Here is the typical example that I have run across:
public partial class Window1: Window
{
public static ObservableCollection<string> TheCollection = new ObservaleCollection<string>();
public Window1()
{
InitializeComponent();
}
}</string></string>
The XAML file:
<Window.Resources>
<CollectionViewSource Source="{Binding Source={x:Static local:Window1.TheCollection}}" x:Key="TheCollectionView"/>
</Window.Resources>
<Grid>
<ListView Name="TheCollectionListView" ItemsSource="{Binding Source={StaticResource TheCollectionView}}" />
</Grid>
What is the syntax for the binding when the ObservableCollection is not static?
I hate to ask what seems to be such a basic question but after several hours of searching I cannot find any example that does not use static.
|
|
|
|
|
Have a look at Bea's site. This post has what you are looking for: http://www.beacosta.com/blog/?p=17[^]
Bea's if the "First Lady" of WPF data binding with many great examples of using the platform.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I'm using Visual Studio 2008 and MS Expression Blend to create a Silverlight application with C# and WPF.
My original goal was to rewrite a WinForms custom-drawn control in Silverlight / WPF, but from what I've seen, simply responding to a paint event and drawing stuff on a surface is a foreign concept to WPF. Fortunately, I found a few places that told me it was possible to simply host a Windows Forms control in a WPF application, which would solve my problem neatly and save me a lot of work in the process. (One such article here.)
The problem is, I can't seem to add any references to Windows Forms or Windows Forms Integration to my project. There don't seem to be any Windows Forms 3.5 assemblies on my system, even though I'm reasonably sure I've installed .NET 3.5 and everything. The only Windows Forms Integration DLL I have is from version 3.0, and I can't add any of these assemblies to my project because they were not built against the Silverlight libraries.
So what am I to do? Everything seems to indicate that hosting a WinForms control in WPF is possible, but does the fact that I am using WPF in Silverlight make this impossible?
If so, my secondary question would be: is there any way to just get a hold of a drawing surface in WPF and render text and shapes to it, like one would do with System.Drawing.Graphics? The new system of creating a bunch of shape objects seems really awkward for my purposes.
Any help would be greatly appreciated!
[Insert witty and relevant signature here]
|
|
|
|
|
You can use OnRender although when you get used to it, WPFs other methods are usually preferable. Silverlight doesn't support hosting Windows Forms controls, I don't know if XBAPs do. While they share quite a lot Silverlight doesn't support everything that WPF does and other parts are work differently.
|
|
|
|
|
Hmm, it doesn't look like I can use OnRender; when using Silverlight, it doesn't seem to exist in UIElement, and the class System.Windows.Media.DrawingContext doesn't exist at all...
EDIT: Yeah, DrawingContext is in PresentationCore.dll, which cannot be added to a Silverlight project because "it was not built against the Silverlight runtime."
[Insert witty and relevant signature here]
|
|
|
|
|
Hi,
We're using SL v1 to play a video streams from a Window Media server. We had no problems when we were using windows media player to play this video, but when using SL, the time slider causes a long pause, very slow rendering the video.
Has anyone solved this problem?
Are there any good sample implementations that someone could point me to?
Thanks.
Shefali
|
|
|
|
|
Hi,
Were you able to resolve this?
I have implemented Silverlight players using "MediaElement" (embedded as part of main Page xaml) as well as the "MediaPlayer" (separate Silverlight control) and both exhibit the same symptoms i.e. playing audio and video slowly. In the case of audio it seems to be repeating three times as it progresses.
Any guidance appreciated!
Thanks,
Alan
|
|
|
|
|
I've been playing with the WPF hands-on lab from the Chicago 'Heroes Happen Here' event a month or so ago. The lab is on line here, but the source code files for the lab aren't there. It's a good lab, and I'd like to study the source code and markup.
Does anyone know whether these source code files are available? If so, where are they posted?
Thanks!
David Veeneman
www.veeneman.com
|
|
|
|
|
Yes via MS site ::
Visual Studio 2008 and .NET Framework 3.5 Training Kit
File Name: VisualStudio2008TrainingKit.exe
Version: 1.0
Date Published: 11/30/2007
Language: English
Download Size: 125.9 MB
http://www.microsoft.com/downloads/details.aspx?FamilyID=8BDAA836-0BBA-4393-94DB-6C3C4A0C98A1&displaylang=en
Got Slack?
|
|
|
|
|
Hi,
does anybody knows what is the WPF way to avoid Tab Selection?
in WinForms i had the Selecting event which i could cancel (with CancelEventArgs)
btw, is there any source of the net that gives you the deifferences?
i found this great document:
Wpf for those who knows WinForms[^]
But it doesn't cover everything, just Layouts, Binding and some general issues (Form Vs Window etc.)
i would love to get other sources like that
thanks,
|
|
|
|
|
Read up on Preview events and the cancelling of them. This code in effect cancels the mouse click so that the tab selection will not take place.
You can get access to the tabitem that was click from the e.OriginalSource and then perform you logic to cancel the mouse click or not.
Private Sub tcOpenPages_PreviewMouseLeftButtonDown(ByVal sender As Object, _
ByVal e As System.Windows.Input.MouseButtonEventArgs) _
Handles tcOpenPages.PreviewMouseLeftButtonDown
Dim bolCancelTabSelection As Boolean = False
'write some code to set bolCancelTabSelection
If bolCancelTabSelection Then
e.Handled = True
End If
End Sub
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I believe you should be able to use SelectionChanged event of TabControl. Such as-
--------------------------
void tb1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems[0] == TbPage1)
{
MessageBox.Show("");
}
//throw new NotImplementedException();
}
-------------------------
-Ajay.
-------------------------
www.componentone.com
-------------------------
|
|
|
|
|
but in SelectionChanged you can't cancel the selection, only add stuff to when it's happening
|
|
|
|
|
Hi all,
I am planning to develop a website which have a simulator where allows users to design thier nail design online. This will be something drag and drop the design to the fingernail in 3D mode,decoration the nail and also display the nail design gallery in 3D which is fully interactive.
I do not want to choose Flash is because it just align the timeframe and simple coding. I want algorithm in my program and it is quite challenge to me to learn.
I posted on C# forum and others as well and they suggest me to use Silverlight. Do anyone have any website related to the Silverlight?Is Silverlight involved algorithm?
Thanks.
|
|
|
|
|
|
Hi all,
I am planning to develop a website which have a simulator where allows users to design thier nail design online. This will be something drag and drop the design to the fingernail in 3D mode.
I would like to ask can this implement in C# with Managed DirectX? And, how do I implement this using C# wi9th Managed DirectX?
Thanks.
|
|
|
|
|
Yes folks, this guy did indeed post this to every forum we have.
Ironically, if you use Silverlight to do this, ( and you probably will ), WPF will be involved.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi All,
I'm still very much a newbie to a lot of C# / WPF and i'm having a bit of trouble making this 'generic' animation type work for me, but I also can't see what the problem is. I've been looking at the code for what already feels like a lifetime and I've gotten nowhere so I'm here now asking silly questions. Sorry for the stack of code below btw.
When I do this:
public void FadeElement(string ElementName, double currentOpacity, double targetOpacity)
{
Storyboard Fade = new Storyboard();
TimeSpan duration = new TimeSpan(0, 0, 0, 0, 500);
DoubleAnimation animation = new DoubleAnimation();
animation.From = currentOpacity;
animation.To = targetOpacity;
animation.Duration = new Duration(duration);
Storyboard.SetTargetName(animation, ElementName);
Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
Fade.Children.Add(animation);
Fade.Begin(this);
}
All works fine.
But I wasn't to 'wrap' this up in a type in a separate library in order to enable me to re-use over and over without having this method in every app I/we make so I did this:
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
namespace Utils.HelperClasses.WPF
{
public sealed class OpacityAnimation : Storyboard
{
#region Fields and Properties
private Storyboard _storyboard;
public string ElementName;
public double CurrentOpacity;
public double TargetOpacity;
public OpacityAnimation()
{
}
public Storyboard CreateOpacityAnimation()
{
_storyboard = FadeElement(ElementName, CurrentOpacity, TargetOpacity);
return _storyboard;
}
private Storyboard FadeElement(string elementName, double currentOpacity, double targetOpacity)
{
Storyboard Fade = new Storyboard();
TimeSpan duration = new TimeSpan(0, 0, 0, 0, 500);
DoubleAnimation animation = new DoubleAnimation();
animation.From = currentOpacity;
animation.To = targetOpacity;
animation.Duration = new Duration(duration);
Storyboard.SetTargetName(animation, elementName);
Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
Fade.Children.Add(animation);
return Fade;
}
#endregion
}
}
but then running this code does nothing but as far as I can tell its more or less the same as doing just the method in the first example with some code abstracted away in the other library:
private void button1_Click(object sender, RoutedEventArgs e)
{
OpacityAnimation oa = new OpacityAnimation();
oa.CurrentOpacity = 1;
oa.ElementName = "button2";
oa.TargetOpacity = 0.3;
oa.CreateOpacityAnimation();
oa.Begin(this);
}
Can anyone offer some insight into what I'm overlooking here?
Thanks,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I started work on something similar using attached properties e.g <Button t:Transition.LoadedTransition="FadeIn" >Button</Button> I then found that markup extensions could not be used for events and I didn't want to create a property for each event, although I think there are a few workarounds. I haven't checked it out yet but the Transitionals project might provide similar functionality. Edit: Also see Kevin's WPF Bag-o-Tricks.
Anyway, with your code I found the problem was that you were inheriting from Storyboard and also creating another inside it and they must have got jumbled up.
public Storyboard CreateOpacityAnimation()
{
FadeElement(ElementName, CurrentOpacity, TargetOpacity);
return this;
}
private void FadeElement(string elementName, double currentOpacity, double targetOpacity)
{
TimeSpan duration = new TimeSpan(0, 0, 0, 0, 500);
DoubleAnimation animation = new DoubleAnimation();
animation.From = currentOpacity;
animation.To = targetOpacity;
animation.Duration = new Duration(duration);
Storyboard.SetTargetName(animation, elementName);
Storyboard.SetTargetProperty(animation, new PropertyPath(Control.OpacityProperty));
Children.Add(animation);
}
You could however just create a static method and reduce the amount of code needed e.g.
public static class Animations
{
public static void Fade(this UIElement control,double targetOpactity,int milliseconds)
{
control.BeginAnimation(UIElement.OpacityProperty,new DoubleAnimation(targetOpactity,new Duration(TimeSpan.FromMilliseconds(milliseconds))));
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
button2.Fade(0.3,500);
}
If your not using C# 3.0 or don't want to use an extension method thats a simple change.
modified on Friday, May 2, 2008 5:51 PM
|
|
|
|
|
Hi Dave,
Fantastic! I'm going to have a good play with this tomorrow. I still don't fully understand inheritace so I had no idea that creating my class would also create a Storyboard.
Thanks for all this info, incredibly useful.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
public static class Animations
{
public static void Fade(this UIElement control,double targetOpactity,int milliseconds)
{
control.BeginAnimation(UIElement.OpacityProperty,new DoubleAnimation(targetOpactity,new Duration(TimeSpan.FromMilliseconds(milliseconds))));
}
}
This is genius!
I take it this is also working along the lines of WPF's handoff animations in that it doesn't care what the current opacity is and will simple animate to the target opacity from its current opacity setting.
Food for thought! Thanks!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|