|
Suppose you allocate a list of Line objects,
public ObservableCollection<Line> Lines = new ObservableCollection<Line>();Populate them with the values that you want. Here, I allocate a set of stroke styles:
public Window1()
{
InitializeComponent();
Lines.Add(AddLineStyle(1, 2, 4));
Lines.Add(AddLineStyle(3, 3, 4));
Lines.Add(AddLineStyle(3, 2, 4));
Lines.Add(AddLineStyle(1, 2, 4));
Lines.Add(AddLineStyle(3, 3, 4));
Lines.Add(AddLineStyle(3, 2, 4));
DataContext = Lines;
}
private Line AddLineStyle(int thickness, int array0, int array1)
{
Line line = new Line();
line.StrokeThickness = thickness;
double[] dashArray = new double[2];
dashArray[0] = array0;
dashArray[1] = array1;
line.StrokeDashArray = new DoubleCollection(dashArray);
return line;
} Now, in my XAML, I just bind to it and set up a simple template:
<Window x:Class="LineDashStyleSample.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<DataTemplate x:Key="LineCombo">
<StackPanel Height="20">
<Line
X1="5"
Y1="5"
X2="190"
Y2="5"
Stroke="Blue"
StrokeThickness="{Binding StrokeThickness}"
StrokeDashArray="{Binding StrokeDashArray}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<StackPanel>
<ComboBox
Width="200"
Height="30"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource LineCombo}" />
</StackPanel>
</Window> This is just a sample - as you're effectively hooking an entire object for just two objects, you could create a lighter weight object and use that instead:
public class DashedLineStyle
{
public int Thickness { get; set; }
public DoubleCollection StrokeDashArray { get; set; }
} Then, you replace the Line type in your ObservableCollection, and the AddLineStyle method to instantiate and return an instance of DashedLineStyle instead. I hope that this helps.
"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
|
|
|
|
|
Many thanks, this is exactly what I was after! =)
Rich
|
|
|
|
|
Cool. Good job.
"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
|
|
|
|
|
Hi
I want to deploy a WPF application using ClickOnce on tablet PC with winXP. Application run fine on Dev. machine and other user's dev. machines also.
But on tablet PC , it crashes with the message:
EventType clr20r3.
P1: ApplicationName.exe
P21.0.0.0
P3 4b68898e
p4: mscorlib
P5: 2.0.0.0
P6 4a7cd8f7 p7: 261 p8:1a
p9: System.argumentnullException
p10 : Nil
On target pc is installed with .NET 1.1, 2.0 sp2, 3.0 sp2 and 3.5 sp1 .
I tried some other sample small and simple wpf applications on same tablet PC, they run properly with same clickOnce deployment
I don't know what's the problem is, need help.
Thanks,
vsaratkar
|
|
|
|
|
try something along the lines:
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
or
Application.Current.DispatcherUnhandledException += UnhandledException;
....
void UnhandledException(.....)
{
Exception ex = .....
MessageBox.Show(ex.StackTrace)
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thanks Super Lloyd
This is the stack Trace
at System.Windows.Markup.XamlParseException.ThrowException(String message, Exception innerException, Int32 lineNumber, Int32 linePosition, Uri baseUri, XamlObjectIds currentXamlObjectIds, XamlObjectIds contextXamlObjectIds, Type objectType)
at System.Windows.Markup.XamlParseException.ThrowException(ParserContext parserContext, Int32 lineNumber, Int32 linePosition, String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.ThrowExceptionWithLine(String message, Exception innerException)
at System.Windows.Markup.BamlRecordReader.CreateInstanceFromType(Type type, Int16 typeId, Boolean throwOnFail)
at System.Windows.Markup.BamlRecordReader.GetElementAndFlags(BamlElementStartRecord bamlElementStartRecord, Object& element, ReaderFlags& flags, Type& delayCreatedType, Int16& delayCreatedTypeId)
at System.Windows.Markup.BamlRecordReader.BaseReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
at System.Windows.Markup.BamlRecordReader.ReadElementStartRecord(BamlElementStartRecord bamlElementRecord)
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
I am using threading in my application. I can't figure out what's wrong.
Please help.
Vsaratkar
|
|
|
|
|
I said something along the lines but it's clearly not enough!
You better show all inner exception (ex, ex.InnerException, ex.InnerException.InnerException, etc..)
and their error messages!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
For the record here is the method I use to retrieve log information from an Exception:
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Diagnostics;
namespace Agtrix.Utility
{
public static class ExceptionUtils
{
public static IEnumerable<Exception> GetAllExceptions(this Exception ex)
{
if (ex == null)
yield break;
yield return ex;
if (ex is ReflectionTypeLoadException)
foreach (Exception ex2 in ((ReflectionTypeLoadException)ex).LoaderExceptions)
foreach (Exception ex3 in GetAllExceptions(ex2))
yield return ex3;
if (ex.InnerException != null)
foreach (Exception ex2 in GetAllExceptions(ex.InnerException))
yield return ex2;
}
public static string ToDetailString(this Exception exception)
{
StringBuilder builder = new StringBuilder();
bool first = true;
foreach (Exception ex in GetAllExceptions(exception))
{
if (!first)
builder.Append("\r\n-------- Caused by Exception --------\r\n");
builder.AppendFormat("Exception : {0}\r\n", ex.GetType());
if (!string.IsNullOrEmpty(ex.Message))
builder.AppendFormat("Message : {0}\r\n", ex.Message);
if (!string.IsNullOrEmpty(ex.Source))
builder.AppendFormat("Source : {0}\r\n", ex.Source);
if (!string.IsNullOrEmpty(ex.HelpLink))
builder.AppendFormat("Help : {0}\r\n", ex.HelpLink);
if (ex.Data.Count > 0)
{
builder.Append("Data\r\n");
foreach (var item in ex.Data.Keys)
{
string key = item.ToString();
string val = string.Format("{0}", ex.Data[item]);
if (val.IndexOfAny(new char[] { '\r', '\n' }) > -1)
builder.AppendFormat("\t{0}:\r\n{1}\r\n", key, val);
else
builder.AppendFormat("\t{0}: {1}\r\n", key, val);
}
}
builder.AppendFormat("Stack :\r\n{0}\r\n", ex.StackTrace);
first = false;
}
return builder.ToString();
}
}
}
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Thanks Super Lloyd for all your help.
My problem is solved.
My application is using SSCE.
In the beginning, we thought setting "Copy Local" property for SqlServerCe.dll in solution explorer to true, will be sufficient for the deployment as target machine was not installed w/ compact DB.
Actually we needed SSCE installed on the target machine.
We did that and application started running on the tablet PC.
Thanks again,
Veena
|
|
|
|
|
Pls, is it possible to capture images on a webcam and insert it in2 a DB in silverlight?
He who goes for revenge must first dig two graves.
|
|
|
|
|
SL4 beta allows access to webcams[^].
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi,
Greetings to you. Yes, you can easily do it using Silverlight 4 Beta. I have one of my article where I described about it. Yup, I only described about capturing video from the webcam. But off-course you can do the image capturing too & then submit it to your Database. Just google or visit Silverlight.Net, you will get a bunch of that.Remember: Please "Mark As Answer", if this answered your query partially or fully.
Thanks & Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | My Articles
|
|
|
|
|
Thanks. But this article of yours, how can i see it? Besides can i get a good tutorial on this? He who goes for revenge must first dig two graves.
|
|
|
|
|
I want to make a Silverlight application, which has a conveyor belt style scrolling list (which has thumbnails of movies) and when one moves the mouse over the thumbnail, it should pause the conveyor belt. When one clicks a particular thumbnail, the movie should get played.
I also want to make this control dynamic (Movies from XML or Database and thumbnails can be static images).
I need the right directions to get started with it...
I tried web search but it didn't helped me a lot.
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|
|
If you're looking for a carousel implementation, see here[^].
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I had seen that control however this is not what I wish to achieve.
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|
|
i have drawn six ellipse using wpf.
<Ellipse Name="e1" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="48,56,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
<Ellipse Name="e2" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="176,56,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
<Ellipse Name="e3" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="296,56,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
<Ellipse Name="e4" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="48,200,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
<Ellipse Name="e5" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="176,200,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
<Ellipse Name="e6" Fill="White" Stroke="Black" HorizontalAlignment="Left" Margin="296,200,0,0" VerticalAlignment="Top" Width="80" Height="80"/>
now i want to access those ellipse using C#. i dont want to call them one-by-one (like e1,e2,e3), but want to call them all in once using for loop (like. for (i=1;i<=6;i++; .... )
How can i do those? can i use those ellipse as variable?
|
|
|
|
|
You could always use the VisualTreeHelper to retrieve them. It's pretty straightforward.
"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 am unable to see the UI portion of XAML in the IDE like WPF in Winforms. Is there any IDE for the XAML development. If I want to do it so that I can design the UI easily what should I do. I have installed Silverlight3 and ExpressionBlend3 along with .Net 3.5 on my machine. Then machine is restarting again and again. I have 1GB RAM and 160GB HD.Can I run all these along with SQL Server 2008.
Please help me I want to practive Blend and Silverlight.
I have downloaded Expression Blend3 and installed. Then my machine is restarting again and again. Is 1 GB RAM not enough for Expression Blend3 or any Virus is getting installed during the download. I want to know whether 1GB RAM is not enough for Blen3. I have 1GB RAM with softwares installed .Net3.5 with Silverlight and Documentation, SQL Server 2008 Evalution Version and .Net 2003 also with Win XP Professional SP2.
Is my machine configuration is not supported for Expression Blend3 please help me how can I practice Expression Blend3.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Abdul,
Check With this Links Once,It might help You...
KAXAML EDITOR[^]
KAXAML Preview[^]
Sundeep G
Sundeep Ganiga
When the only tool you have is a hammer, everything looks like a nail.
Come Forth Yourself to Click "Good Answer" for any expected solution.
Let us Support our C Project Programmers who provide solutions here.
|
|
|
|
|
Not an IDE, but more of an editor[^].
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
I need to develop a Silverlight application. Can I use any of these for that purpose. If not Please give me some other links also. Because I am unable to run Expression Blend 3 in my machine.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
You can edit your xaml file, but you definitely cannot get the features provided by Expression Blend in XAML Pad.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi Sandeep,
I have used both the XAMLPad and KAXAML. In both of these two I am unable to drog and drop the controls. But anyways I managed to create some controls in KAXAML. When I paste that in my .Net(web silverlight) projects xaml it is not compiling.
Why Microsoft has created so many softwares silverlight, xaml, expression blend and so on. My Laptop with 1GB RAM is unable to run with all these installed. If he is creating why is he not supplying Laptop to every developer.
Thanks & Regards,
Md. Abdul Aleem
NIIT technologies
|
|
|
|
|
Hey guys, I've been working with c# (win programming) and ASP.NET for a while and I wanted to start with WPF, what do you suggest me doing ?
Do you think moving to WPF is a wise choice and if it is, what do you recommend (the main reason I'm going after this is the stunning visual effect that I provides, and I need something like this in some of my projects).
Thx
|
|
|
|
|