The WPF / Silverlight Zone
Using WPF and Silverlight enables you to rapidly build powerful software user interfaces across the Web, desktop, mobile devices and more. Today’s latest XAML tools and technologies can help you create real world, reusable solutions with standard programming languages (C#, VB.NET, et al) on the foundations of the .NET Framework which hides the details of the underlying OS and hardware and supplies Base Class Libraries that handle common programming tasks.
Learn to leverage support for data access, networking, security, and rich, high-fidelity user interfaces like never before with the articles in our WPF/Silverlight Learning Zone, covering everything from fundamentals to advanced topics like performance, data visualization and user experience. These resources are here to help you enhance your skill set and productivity.
Building today’s software applications is made easier by using the right .NET tools, including the WPF, Silverlight, ASP.NET, Windows Forms, and jQuery controls offered by Infragistics. Get the rich features you’ve seen in other pieces of software implemented in a time-saving, enhanced user interface (UI) control toolset by downloading a fully-functional, free trial or trying the online samples below to see for yourself.
Additional Resources
 |
Samples Browser
Explore these online samples for Microsoft Silverlight, using Infragistics user interface controls like grids, charts, trees, tabs, ribbons and more. Each sample is accompanied by XAML and/or C# source code demonstrating how easily it’s achieved. |
 |
WorldStats
Dive into an immersive and animated Rich Internet Application (RIA) user experience that visualizes the story of global population growth, per-capita wealth, improvements in infant mortality, and other key statistics.
|
 |
Finance
Check out the capabilities of the data chart, tree map, and zoom bar controls for the Financial Services industry. Optimized for high-speed financial charting the data chart performs easily handles large datasets made up from millions of data points featuring real-time updates. |
 |
Download a free trial of Infragistics
NetAdvantage Ultimate to get 6 user interface toolsets for line of business and data visualization today in one package (299 MB). |
Featured Article
 |
by Shai Raiten
Getting Started with Kinect - Create Project, Control the Camera Angle and use Skeleton Tracking
|
Articles
 |
by Ivan Krivyakov
This is an alternative for "Persist the Visual Tree when switching tabs in the WPF TabControl...
|
 |
by Paulo Zemek
This article explains how to create a class that can handle any kind of data-type conversion by...
|
 |
by Nick Polyak
JavaScript/DOM basics for WPF/Silverlight/C# developers
|
 |
by ntg123
A simple technique to achieve Bindable-ConverterParameter in WPF's XAML.
|
 |
by Harry von Borstel
Develop your applications quicker and make them more robust with typesafe binding.
|
 |
by RakeshGunijan
Silverlight uer control validation display techniques.
|
 |
by David Veeneman
How to get a Prism 4 line-of-business application up and running, using WPF and the Unity...
|
 |
by Xiaojie Liu
A Silverlight color picker (looks like ComboBox), more like the one used within VS 2010 property...
|
 |
by Yevhen Bobrov
Simplifying programming of asynchronous WCF service calls and asynchronous programming in general.
|
Discussions
|
|
 |
 |
All WinRT discussions are now in Windows API and WinRT[^]
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
made stackedbarseries in silverlight to show "projects gantt chart"
now I wanna change the numbers shown in the Axes-X for example we have Worker John:
pr1: 201105 - 201115
pr2: 201120 - 201144
pr3: 201142 - 201207
etc...
so I made 2 series that the first seria is with tranceparent color then I make function that change the WW to range from 201101 (dont need before..) so the chart looks like:
pr1: 5-15
pr2: 20-44
pr3: 42-60 (53+7 or 52+7 depends on year)
now how can I change the Axes display to the original?
the code in xaml is:
<toolkit:Chart Name="ProjectChart" Title="Projects" Visibility="Visible" >
<toolkit:Chart.Series>
<toolkit:StackedBarSeries FontWeight="Bold" MouseLeftButtonUp="StackedBarSeries_MouseLeftButtonUp" MouseEnter="StackedBarSeries_MouseEnter">
<toolkit:SeriesDefinition ItemsSource="{Binding}" Visibility="Collapsed" Title="" Name="serEmpty"
DependentValueBinding="{Binding tranceparent_ser}"
IndependentValueBinding="{Binding projectName}"
>
<toolkit:SeriesDefinition.DataPointStyle>
<Style TargetType="toolkit:BarDataPoint">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</toolkit:SeriesDefinition.DataPointStyle>
</toolkit:SeriesDefinition>
<toolkit:SeriesDefinition ItemsSource="{Binding}" Title="Project" Name="serProjects"
DependentValueBinding="{Binding project_ser}"
IndependentValueBinding="{Binding projectName}">
<toolkit:SeriesDefinition.DataPointStyle>
<Style TargetType="toolkit:BarDataPoint">
<Setter Property="Background" Value="Blue"/>
<Setter Property="BorderBrush" Value="Blue"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
</toolkit:SeriesDefinition.DataPointStyle>
</toolkit:SeriesDefinition>
</toolkit:StackedBarSeries>
</toolkit:Chart.Series>
</toolkit:Chart>
thanks
|
|
|
|
 |
I have an XML file structured this way:
<Emulators>
<Settings>
<vol name="10"/>
<Volume>10</Volume>
<Keys name="key1" value="1" />
<Keys name="key2" value="2" />
<Keys name="key3" value="3" />
<Keys name="key4" value="4" />
</Settings>
<System>
<Name>name1</Name>
<Icon>name1.png</Icon>
<topplayed>
<Top>top1</Top>
<Top>top2</Top>
<Top>top3</Top>
</topplayed>
</System>
<System>
<Name>name2</Name>
<Icon>name2.png</Icon>
<topplayed>
<Top>top4</Top>
<Top>top5</Top>
<Top>top6</Top>
</topplayed>
</System>
</Emulators>
I get no difficulties binding to tag, as well as tags contained into it.
I get no difficulties to bind the tag into a list box.....but I don't know how to bind to tags into .
How to populate a listbox with all elements of the currently selected ?
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="721" Width="525" removed="#FF4E4E64">
<Grid Name="Grid1">
<Grid.DataContext>
<XmlDataProvider x:Name="SystemData" Source="C:\Users\Portable\Desktop\taper\WpfApplication1\Resources\Systems2.xml" XPath="Emulators" />
</Grid.DataContext>
<Grid.Resources>
<DataTemplate x:Key="Resource1">
<Label Content="{Binding XPath=@name}"/>
</DataTemplate>
<DataTemplate x:Key="Resource2">
<Label Content="{Binding XPath=@value}"/>
</DataTemplate>
<DataTemplate x:Key="Resource3">
<Label Content="{Binding XPath=Name}"/>
</DataTemplate>
<DataTemplate x:Key="Resource4">
<Label Content="{Binding XPath=Top}"/>
</DataTemplate>
</Grid.Resources>
<TextBox Text="{Binding XPath=Settings/Volume}" Height="30" HorizontalAlignment="Left" Margin="12,12,0,0" Name="TextBox5" VerticalAlignment="Top" Width="196" />
<ListBox ItemsSource="{Binding XPath=Settings/Keys}" ItemTemplate="{StaticResource Resource1}" IsSynchronizedWithCurrentItem="True" Height="92" HorizontalAlignment="Left" Margin="12,48,0,0" Name="ListBox1" VerticalAlignment="Top" Width="196" />
<ListBox ItemsSource="{Binding XPath=Settings/Keys}" ItemTemplate="{StaticResource Resource2}" Height="92" HorizontalAlignment="Left" IsSynchronizedWithCurrentItem="True" Margin="214,48,0,0" Name="ListBox2" VerticalAlignment="Top" Width="196" />
<ListBox ItemsSource="{Binding XPath=System}" ItemTemplate="{StaticResource Resource3}" IsSynchronizedWithCurrentItem="True" Height="104" HorizontalAlignment="Left" Margin="12,185,0,0" Name="ListBox3" VerticalAlignment="Top" Width="196" />
<ListBox ItemsSource="{Binding XPath=System/topplayed}" ItemTemplate="{StaticResource Resource4}" Height="74" HorizontalAlignment="Left" Margin="12,295,0,0" Name="ListBox4" VerticalAlignment="Top" Width="196" />
</Grid>
</Window>
Thank you very much!!
|
|
|
|
 |
Hi All, I need to play streaming videos like Live TV News and live Cricket etc. in my WPF Application. I used Media Element But it did not worked out. If anyone has done that in any way please help me out.
|
|
|
|
 |
Take a look at the sticky at the top on how to ask a question, yours was not a good example and will not get the answer you want. Try reading some of the articles, work through the samples[^] there are plenty out there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
 |
So I have this XAML code:
<Window.Resources>
<local:MainViewModel x:Key="ViewModel" />
</Window.Resources>
And this is the XAML for the actual control:
<StackPanel Orientation="Horizontal" Width="897" Margin="5" DataContext="{StaticResource ViewModel}">
<ItemsControl Width="897" ItemsSource="{Binding Intersections}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<WrapPanel Width="897" >
<RadioButton GroupName="Intersections"
Content="{Binding Text}"
IsChecked="{Binding IsChecked, Mode=TwoWay}" Width="150"/>
</WrapPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
In the code behind I have this public class:
Public Class MainViewModel
Sub New()
Intersections.Add(New Insertion() With {.Text = "Item 1"})
Intersections.Add(New Insertion() With {.Text = "Item 2", .IsChecked = True})
Intersections.Add(New Insertion() With {.Text = "Item 3"})
Intersections.Add(New Insertion() With {.Text = "Item 4"})
End Sub
Private _Intersections As New ObjectModel.ObservableCollection(Of Insertion)
Public Property Intersections() As ObjectModel.ObservableCollection(Of Insertion)
Get
Return _Intersections
End Get
Set(ByVal value As ObjectModel.ObservableCollection(Of Insertion))
_Intersections = value
End Set
End Property
Public Class Insertion
Private _Text As String
Public Property Text() As String
Get
Return _Text
End Get
Set(ByVal value As String)
_Text = value
End Set
End Property
Private _IsChecked As Boolean
Public Property IsChecked() As Boolean
Get
Return _IsChecked
End Get
Set(ByVal value As Boolean)
_IsChecked = value
End Set
End Property
End Class
End Class
The problem Im haveing is to get the RadioButtons to be shown Horizantaly, and I cant figure out how to do that. I have tried to set IsItemsHost="True" but Its giving me the error "A panel with IsItemsHost="true" is not nested in an ItemsControl. Panel must be nested in ItemsControl to get and show items.". Either I heave tried to do this in all the wrong places or Im missing some key information here.
To be clear the code works, but its giving me a stack of the RadioButtons, but I want the side by side like a WrapPanel.
The example is taken from here here[^], and I converted it to VB from C#.
modified 2 days ago.
|
|
|
|
 |
Use ItemsPanelTemplate and put the radio buttons horizontally inside a stack panel.
E.g.
<ItemsControl.ItemTemplate>
<ItemsPanelTemplate>
<StackPanel Orientation='Horizontal' "/>
</ItemsPanelTemplate>
|
|
|
|
 |
I tried this:
<StackPanel Orientation="Horizontal" Width="897" Margin="5" DataContext="{StaticResource ViewModel}">
<ItemsControl Width="897" ItemsSource="{Binding Intersections}">
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal">
<RadioButton GroupName="Intersections"
Content="{Binding Text}"
IsChecked="{Binding IsChecked, Mode=TwoWay}" Width="150"/>
</StackPanel>
</ItemsPanelTemplate>
</ItemsControl>
</StackPanel>
But this time it wont build properly with ItemsPanelTemplate, I have seen this on the webbefore also, but couldnt get it to work, Can you?
|
|
|
|
 |
I think (though Im not sure), one needs to put the tag somewhere.
|
|
|
|
 |
ITs working now, but its a strange code, and its well over a page long, so I dont think I'll be pasting it here, unless you are really interested
|
|
|
|
 |
Ok Found the answer here[^] . The code that works looked like this:
<StackPanel Orientation="Horizontal" Width="897" Margin="5" DataContext="{StaticResource ViewModel}">
<ItemsControl Width="897" ItemsSource="{Binding Intersections}">
<ItemsControl.Template>
<ControlTemplate>
<WrapPanel Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"
FlowDirection="LeftToRight" IsItemsHost="true">
</WrapPanel>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemTemplate>
<DataTemplate>
<WrapPanel Width="120">
<RadioButton GroupName="Intersections" Content="{Binding Text}" IsChecked="{Binding IsChecked, Mode=TwoWay}" Width="150"/>
</WrapPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
|
|
|
|
 |
I have this combobox:
<ComboBox x:Name="cboServerList"
Grid.Row="0"
Grid.Column="1"
Margin="5"
Height="23"
IsEditable="True"
ItemsSource="{Binding Servers}"
SelectedItem="{Binding SelectedServer}"
TextSearch.TextPath="ServerName"
Text="{Binding ServerName}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding ServerName}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Since it's editable, as soon as I start typing the SelectedServer property's setter fires. How can I set it up so that it doesn't fire until the user presses Enter or tabs out?
Thanks
If it's not broken, fix it until it is
|
|
|
|
 |
Set the UpdateSourceTrigger of the binding to LostFocus. That won't handle the enter key though. Which is probably ok since the enter key has a different meaning. Dunno why you'd want to do this though. Sounds like an issue with your VM setter being too expensive??
|
|
|
|
 |
Thanks for the tip
SledgeHammer01 wrote: Dunno why you'd want to do this though. Sounds like an issue with your VM
setter being too expensive??
Why would you want the property's get to fire on each keystroke?
If it's not broken, fix it until it is
|
|
|
|
 |
Kevin Marois wrote: Why would you want the property's get to fire on each keystroke?
Who cares if you update a string 50 times? What do you think happens with WPF controls? If you scroll down a combo box, you'll get a bunch of updates for each item too.
If you are binding to expensive setters, your design is wrong. In your example, it is perfectly fine to update a string property 50 times, but if that is also triggering 50 database updates, then thats an improper design.
You are trying to solve the wrong problem here I think .
|
|
|
|
 |
SledgeHammer01 wrote: Who cares if you update a string 50 times?
I care. This is a search field. I don't want the search running after every keystroke. Of course it's bound to a property. How else would you do it?
SledgeHammer01 wrote: If you are binding to expensive setters, your design is wrong. In your example,
it is perfectly fine to update a string property 50 times, but if that is also
triggering 50 database updates, then thats an improper design
This is exactly what I'm trying to avoid. That's why I don't want the setter to execute until the user presses enter. That's a pretty normal requirement.
If it's not broken, fix it until it is
|
|
|
|
 |
Ok... I'm confused. There are two ways to do search:
1) a real-time live search (i.e. Google, Internet Explorer, etc)
2) only do the search when the user clicks the OK / search button
For #1, you would do it on every key stroke.
For #2, it depends on how your UI is laid out. Do you have a pop up dialog with an OK button? Or is it something like where you have an edit box in the main window frame?
Irregardless of how you are implementing #2 UI wise, I think you are confusing your property setter with your action trigger. Those should be separate. The "public string SearchText" property should not kick off a search. Since all you should be doing in it is updating the property, its fine to update it 50 times. Then your enter key / ok / search button will send a command to the VM to kick off the search.
The button sending the command portion I'm assuming you already know how to do, for trapping the enter key, all you need to do is use your EventToCommand mapper to map the KeyDown event of the edit box to an ICommand and forward along the eventArgs. In your command handler function, you would simply check if the key pressed was the enter key. All nice and MVVM'y .
|
|
|
|
 |
SledgeHammer01 wrote: Ok... I'm confused. There are two ways to do search: 1) a real-time
live search (i.e. Google, Internet Explorer, etc) 2) only do the search when
the user clicks the OK / search button
Ok, well that's just your opinion. I can point out mroe than a few UI designs where search happens when the user types, and also where nothing happens until you press enter. Open up Windows Explorer and type something into the search field. Nothing happens until you press enter. There's no button, becuase it's an extra step. Type, then reach for the mouse. Bad design IMHO. For heads down work, press enter to confim/trigger and action.
At any rate, I'll set the UpdateSourceTrigger of the binding to LostFocus.
If it's not broken, fix it until it is
|
|
|
|
 |
Lol... you just described #1 and #2. #2 is trigger based, I thought it was implied that the trigger could be ANYTHING whether it be a button, the enter key, or you stepping on your cats tail. Silly me.
At any rate, I'll let others help you from now on, as you are kind of rude to people who help you for free on thier own time .
|
|
|
|
 |
SledgeHammer01 wrote: At any rate, I'll let others help you from now on, as you are kind of rude to
people who help you for free on thier own time .
Wow, sorry. I didn't mean to be rude. Sorry if I came across that way.
If it's not broken, fix it until it is
|
|
|
|
 |
I have previous experience using WinForms and the DataGridView control. I am trying to re-code a previous program using WPF that reads a parts list from a delimited text file and displays results in a DataGrid control.
In WinForms, I was able to assign a tag to the DataGrid row that I used to link individual URLs to our company's HTML-based inventory program. However, I am unsure how to do this (if it's even possible) in WPF. Currently, I read from the text file and load its contents into a List. From there, I filter the List by whatever the user selects, then display the results in a DataGrid control. I want to open up the browser when the user selects a row, but can't figure out how to bind the URL to the row. Is this possible? If so, can someone help point me in the right direction?
Thanks.
|
|
|
|
 |
As long as you use data binding to bind your data to the grid, you really don't have much of a problem. Each row will be bound to the original item in the list, so it's simply a matter of reading from your SelectedItem, which will return the real item you are bound to.
|
|
|
|
 |
Hi Pete,
Thanks for the response! I am not sure what you are suggesting. I am binding the data from the List into separate columns in my DataGrid. But instead of returning the information in the DataGrid, I want to open a browser window and go to the URL.
It's hard to explain without pictures, but I have a DataGrid with 6 columns. Under column 1, I list a description, with a hyperlink look. I bind the description of the part to that column. When the user clicks on that row, that's when I want to open the browser window. I thought about just using a DataGridHypertextColumn, but every example I could find online used an absolute address (http://exampleaddress.com). I will need to read the address from a textfile database. I suppose I could add another column and bind the URL to its own DataGrid column, but I am trying to avoid that.
Since I can't upload pictures, I have included the code.
private List<addData> LoadCollectionData()
{
List<addData> readData = new List<addData>();
string searchLine = (machineComboBox.SelectedValue.ToString()).ToUpper();
string findLine = searchTextBox.Text.ToUpper();
foreach (string readLine in File.ReadAllLines(path))
{
if (readLine.Contains(searchLine) && readLine.Contains(findLine))
{
string[] myData = readLine.Split('|');
readData.Add(new addData()
{
description = myData[0],
ICN = myData[1],
RIN = myData[2],
indexCode = myData[3],
location = myData[4],
machine = myData[5]
});
webLink = myData[6];
}
}
return readData;
}
And here is the XML:
<DataGridTextColumn Header="Part Name" CanUserResize="True" Width="225" Binding="{Binding description}">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20"/>
<Setter Property="FontWeight" Value="Black"/>
<Setter Property="TextElement.Foreground" Value="Blue"/>
<Setter Property="TextDecorations" Value="Underline"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="Cursor" Value="Hand"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
I apologize for being a little slow in understanding what you have explained so far, but I am very new to WPF and DataGrid seems much more complicated than it was in WinForms.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Infragistics Whitepapers
|
|