|
There's lots of ways to accomplish this.
If you want to use a ListBox, you could
1) remove your scrollviewer to use the one in the listbox
2) re-template the listbox as show in the sample code here:
ItemsControl.ItemsPanel Property[^]
setting the scrollviewers scrollbarvisibility properties to Hidden
3) At runtime, find the listbox's scrollviewer so you can manipulate it
programmatically, as shown here: Access ScrollViewer from within a style[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for letting me understand the tree structure of the controls in WPF.
the posts you have directed to, are surely helpful.
I tried the same tree structure, and code.
(Correct me if I am wrong but, the code I have seen also had scrollviewer inside the border control, I also tried removing scrollviewer(to use listbox's default) as you said earlier but it stopped scrolling, then I put it back as the code sujjested and as per my previous working Markups)
Now, the main thing is that, after trying it, All I could get is step by step scrolling which I was getting before too.
I intend to get smooth scrolling, just like you hold scroll bar and move little up/down, but on click of my up/Down buttons.
thanks for the reply, it cleared my other doubts though.
|
|
|
|
|
Hi
I recently did some digging on the internet and I found a way to use the Vista Aero theme in Windows XP. One can simply add the following line of code to the App.xaml file:
<ResourceDictionary Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml"/>
Now my question is, how can I specify this line of code when I already have other styles etc. specified in the App.xaml file? It gives me an error saying "Cannot add element to property 'Resources', because the property can have only one child element if it uses an explicit collection tag". It works when I remove everything else from App.xaml though.
|
|
|
|
|
You need to use a merged dictionary. Here's one from one I'm working on right now:
<Application
x:Class="Goldlight.SampleApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/BureauBlue/Theme.xaml"/>
<ResourceDictionary Source="Goldlight.Resources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
"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
|
|
|
|
|
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="...aero etc etc..."/>
<ResourceDictionary Source="...your dictionary..."/>
<ResourceDictionary Source="...and many more..."/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
EDIT: Ah well, Pete beat me to it.
|
|
|
|
|
Good job though.
"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
|
|
|
|
|
I've create some web services that return, for example, a List<myclass> to the client and it is been working fine.
But now I'm trying to pass a List<myclass> as parameter from the client to a function in a web service but it does not compile. The compiler only accepts it if the List is of type object as in List<object>
Is it possible to acomplish what I'm trying to do or it only works if is List<object>?
Is there any other way to send the list to the server (Maybe FTP or something else)?
Any link to a good explanation on how to work with List<object> ?
Thanks
|
|
|
|
|
The error actually happens in the app side and not in the web. private List<person>
myList = new List<person>(); // Same as declared in the web side
// Populate myList with some items .......
private void btn_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.Service1Client proxy = new SilverlightApplication2.ServiceReference1.Service1Client();
proxy.SetPersonsCompleted += new EventHandler<system.componentmodel.asynccompletedeventargs>(proxy_SetPersonsCompleted);
proxy.SetPersonsAsync(myList);} // This line always underlined in blue by the compiler
void proxy_SetPersonsCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
throw new NotImplementedException();
}
public class Person
{ public string name;
public int age;
}
Here is the error:
Error 1 The best overloaded method match for 'SilverlightApplication2.ServiceReference1.Service1Client.SetPersonsAsync(System.Collections.ObjectModel.ObservableCollection<silverlightapplication2.servicereference1.person>)' has some invalid arguments E:\SilverlightApplication2\Views\Home.xaml.cs 35 13 SilverlightApplication2
Error 2 Argument '1': cannot convert from 'System.Collections.Generic.List<silverlightapplication2.person>' to 'System.Collections.Generic.List<silverlightapplication2.servicereference1.person>' E:\SilverlightApplication2\Views\Home.xaml.cs 35 35 SilverlightApplication2
|
|
|
|
|
hi..
There is one solution to it.. in your webservice create a List<Objects> populate it and pass it back to your silverlight solution,
now while reading the data from the object list to should have the class which will hold this data, use IEnumerater to go thru your list
and get the data
IEnumerator enumerator = e.Result.(Yourlist).GetEnumerator();
for (int i = 0; i < e.Result.(Yourlist).Count; i++)
Person = new person();
person.name= (yourList).toString();
person.Age= (int)(yourList);
Hope this helps u... :=)
|
|
|
|
|
I want to send the list to the web service not the other way around. For this there is an easier solution: Just send the list as a return value of the function call to the web service.
In your example what is enumerator used for?
|
|
|
|
|
CBenac wrote: Error 1 The best overloaded method match for 'SilverlightApplication2.ServiceReference1.Service1Client.SetPersonsAsync(System.Collections.ObjectModel.ObservableCollection)' has some invalid arguments E:\SilverlightApplication2\Views\Home.xaml.cs 35 13 SilverlightApplication2
Shouldn't you be using an ObservableCollection<> instead of a List<> on the
client side, since that's what the generated code is expecting?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, you are right this is true indeed. But, it is not all, there is more to be done. I found an example that may work. I'll try it and post the result here.
Thanks
|
|
|
|
|
CBenac wrote: But, it is not all, there is more to be done
I guess I missed the problem then.
You stated "The compiler only accepts it if the List is of type object"...
When I define a service like this:
namespace TestWcfServiceLibrary
{
[ServiceContract(Namespace = "")]
public interface ISilverlightService
{
[OperationContract]
void SetPersons(List<Person> personlist);
}
public class SilverlightService : ISilverlightService
{
public void SetPersons(List<Person> personlist)
{
}
}
public class Person
{
public string name;
public int age;
}
}
...I get this generated for the client:
public System.IAsyncResult BeginSetPersons(System.Collections.ObjectModel.ObservableCollection<SilverlightTester.SilverlightServiceReference.Person> personlist, System.AsyncCallback callback, object asyncState) {
object[] _args = new object[1];
_args[0] = personlist;
System.IAsyncResult _result = base.BeginInvoke("SetPersons", _args, callback, asyncState);
return _result;
}
public void EndSetPersons(System.IAsyncResult result) {
object[] _args = new object[0];
base.EndInvoke("SetPersons", _args, result);
}
There shouldn't be any compiler errors using that client side code.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I think the problem may be that the parameter is not been initialized correct in the client side. Would it be possible to show an example on how to call it from the client side?
Here is how it's been called:
//ObservableCollection<People> people = new ObservableCollection<People>();
List<People> people = new List<People>();
private void btnTestList_Click(object sender, RoutedEventArgs e)
{
ServiceReference1.Service1Client proxy2 = new AppListParam.ServiceReference1.Service1Client();
proxy2.SetListCompleted += new EventHandler<AppListParam.ServiceReference1.SetListCompletedEventArgs>(proxy2_SetListCompleted);
proxy2.SetListAsync(people);
}
void proxy2_SetListCompleted(object sender, AppListParam.ServiceReference1.SetListCompletedEventArgs e)
{
MessageBox.Show(e.Result);
}
}
public class People
{
public string Name;
public int Age;
}
Now, in another issue, why the code in my SL3 is generated different from the one in your example? There is no interface as you can see.
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1
{
[OperationContract]
public string SetList(List<People> people)
{
// Add your operation implementation here
return "OK";
}
// Add more operations here and mark them with [OperationContract]
}
public class People
{
public string Name;
public int Age;
}
|
|
|
|
|
CBenac wrote: Would it be possible to show an example on how to call it from the client side?
Not without seeing the generated client-side interface code.
CBenac wrote: Now, in another issue, why the code in my SL3 is generated different from the one in your example? There is no interface as you can see.
The lack of an interface is probably why it doesn't work.
WCF requires an interface to define the contract.
Maybe try something like this (make sure your service endpoint contract specifies yournamespace.IService1):
[ServiceContract(Namespace = "")]
public interface IService1
{
[OperationContract]
public string SetList(List<People> people);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string SetList(List<People> people)
{
return "OK";
}
}
public class People
{
public string Name;
public int Age;
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
OK I'll implement the interface but why silverlight doesn't do it automatically when the service is created? Also, the other services are working fine without the interface implementation.
|
|
|
|
|
CBenac wrote: the other services are working fine without the interface implementation
I just know when you use the interface, the client side code is generated
correctly and automatically.
If it works without the interface, go for it.
But then you may not even be using automatically generated code on
the client, I don't know...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have the following code that is suposed to loop through a number of images but sends out a blank page for the first images and only displays the last one in the list.
namespace WpfApplication5
{
public partial class App : System.Windows.Application
{
void OnStartup(Object sender, StartupEventArgs e)
{
Window1 primaryWindow = new Window1();
primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
System.Drawing.Rectangle location = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
primaryWindow.WindowState = WindowState.Maximized;
string Path = Environment.CurrentDirectory + "\\images";
foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
{
if (screen == System.Windows.Forms.Screen.PrimaryScreen)
{
Window1 window = new Window1();
window.Photos = (PhotoCollection)(this.Resources["Photos"] as ObjectDataProvider).Data;
window.Photos.Path = Environment.CurrentDirectory + "\\Images";
for (int i = 0; i < window.Photos.Count; ++i)
{
window.WindowStartupLocation = WindowStartupLocation.Manual;
location = screen.Bounds;
window.Left = location.X - 7;
window.Top = location.Y - 7;
window.Width = location.Width + 14;
window.Height = location.Height + 14;
if (i > 0)
System.Threading.Thread.Sleep(40);
window.ScreenSaver(window.Photos[i].Source);
window.Show();
}
}
}
}
}
}
public partial class Window1 : System.Windows.Window
{
public PhotoCollection Photos;
public Window1()
{
InitializeComponent();
}
void OnLoaded(object sender, EventArgs e)
{
TypeConverter colorTypeConverter = TypeDescriptor.GetConverter(typeof(Color));
Background = new SolidColorBrush((Color)colorTypeConverter.ConvertFrom(Properties.Settings.Default.BackgroundColor));
}
public void ScreenSaver(string imagepath)
{
StackPanel mainPanel = new StackPanel();
Window1 window = new Window1();
ImageBrush picturebrush = new ImageBrush();
picturebrush.ImageSource =
new BitmapImage(
new Uri(imagepath, UriKind.Relative)
);
Canvas myCanvas = new Canvas();
System.Drawing.Rectangle location = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
window.Left = location.X - 7;
window.Top = location.Y - 7;
myCanvas.Width = location.Width + 14;
myCanvas.Height = location.Height + 14;
myCanvas.Background = picturebrush;
mainPanel.Children.Add(myCanvas);
this.Content = mainPanel;
modified on Tuesday, October 6, 2009 10:11 AM
|
|
|
|
|
Please post your question once only. Also it would be helpful if you put your code between <pre></pre> tags so it is correctly formatted and readable. See the posting guidelines here[^].
|
|
|
|
|
havegunwilltravel wrote: System.Threading.Thread.Sleep(40);
40 THOUSANDTHS of a second ? You need to rethink all of this. A better option would be to use a timer, not to make the thread sleep when it should be updating a photo.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I have the following code that is suposed to loop through a number of images but sends out a blank page for the first images and only displays the last one in the list.
namespace WpfApplication5
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : System.Windows.Application
{
void OnStartup(Object sender, StartupEventArgs e)
{
//creates window on primary screen
Window1 primaryWindow = new Window1();
primaryWindow.WindowStartupLocation = WindowStartupLocation.Manual;
System.Drawing.Rectangle location = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
primaryWindow.WindowState = WindowState.Maximized;
string Path = Environment.CurrentDirectory + "\\images";
//creates window on other screens
foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
{
if (screen == System.Windows.Forms.Screen.PrimaryScreen)
{
Window1 window = new Window1();
window.Photos = (PhotoCollection)(this.Resources["Photos"] as ObjectDataProvider).Data;
window.Photos.Path = Environment.CurrentDirectory + "\\Images";
for (int i = 0; i < window.Photos.Count; ++i)
{
window.WindowStartupLocation = WindowStartupLocation.Manual;
location = screen.Bounds;
//covers entire monitor
window.Left = location.X - 7;
window.Top = location.Y - 7;
window.Width = location.Width + 14;
window.Height = location.Height + 14;
if (i > 0)
System.Threading.Thread.Sleep(40);
window.ScreenSaver(window.Photos[i].Source);
window.Show();
}
}
}
}
}
}
|
|
|
|
|
I have a datagrid being populated from a datatable which contains several computed columns. If the computed cell value is >= to the previous day's value, I want the font color to stay the same. If the value is < than the previous day's value, I want to change the font for that particular cell red (not the entire row). Is that possible? In the WinForm datagridview it wasn't a big deal.
I'm new to WPF and the datagrid, but am I missing something simple here to accomplish the same task?
Thanks for any pointers or help.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
You should easily be able to accomplish this via DataTriggers.
"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
|
|
|
|
|
Roger that gold leader. Let me go looking into datatriggers.
Thanks!
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi to all:
Please could someone help me!
I am new to Silverlight but trying to get my head around the format and structure of it all.
I am experimenting with different ways of designing a web site and encountered the following problem.
What I am trying to do in a nutshell is to host a Silverlight control from a Silverlight application. To be more specific; from a *.Xaml file. My example is below:-
I am using a third party Silverlight control called Vertigo.Slideshow (I'm sure you will have heard of it).
From a website (Html coded page) I just do the following
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Gallery</title>
<script type="text/javascript" src="../Scripts/Release/Silverlight.js"></script>
<script type="text/javascript" src="../Scripts/Release/SlideShow.js"></script>
</head>
<body>
<div id="content_container">
<script type="text/javascript">
new SlideShow.Control(new SlideShow.XmlConfigProvider());
</script>
</div>
</body>
I then just add a Data.Xml file (with refs to all images) and also a Configuration.Xml to my current folder. This all works perfectly fine.
However, I've created a new web site in Visual Studio 2008 using 'Silverlight Navigation Application'.
So all my web pages are in the *.Xaml format.
What I'm trying to do is add this Vertigo.Slideshow.Xap control to my web page (Xaml) but really, really struggling. I know I must be doing something fundamentally wrong but cannot seem to resolve it.
I would really appreciate any help whatsoever to anyone who can shed some light on this (or even a snippet of code which will do this).
I would be eternally grateful to whomever gives me a pointer.
Thanks in advance.
Regards
Richard
|
|
|
|