|
|
But does 1000 characters take 1 megabyte to save? It actually takes 1 kilobyte.
My isolated storage variable says I have tons of free space.
The odd thing is that the stream writer doesn't throw an error.
Brent
|
|
|
|
|
Sorry, there was another unrelated error that was interrupting the stream flushing. Fixed it and now I'm getting my entire file.
Brent
|
|
|
|
|
Well. Thanks for posting the solution.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
The following line does not compile in silverlight 4.0
XmlDocument myFile = new XmlDocument();
Note that I do have a reference to system.xml and also using the
using System.Xml namespace
Any thoughts please?
Thanks
|
|
|
|
|
You can't really use XMLDocument.
What you need to do is use XDocument and do something like -
XDocument myFIle = XDocument.Parse(xmlContent);
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I agree that he should probably use the newer classes, he can still use XmlDocument that way if he wants to. See my answer to his question.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Try this. It's an example I found - using google - on the MSDN web site :
using System.IO;
using System.Xml;
using System.Xml.Schema;
private void LoadXmlData()
{
XmlValidatingReader reader = null;
XmlTextReader txtReader = null;
string filename = "myfilename.xml";
try
{
txtReader = new XmlTextReader(filename);
reader = new XmlValidatingReader(txtReader);
reader.ValidationType = ValidationType.DTD;
reader.ValidationEventHandler += eventHandler;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
}
finally
{
if (reader != null)
{
reader.Close();
}
}
}
void ValidationCallback(object sender, ValidationEventArgs args )
{
}
EDIT ===
I missed the fact that you're using Silverlight. Loading a client-side file can be problematic if nigh impossible (unless you're running out of browser and the file is in a specific place).
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Ah I see. Thanks.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
In my solution, there is a silverlight 4.0 project as well as the web host project.
Question:
From one of the .xaml files i.e. mainpage.xaml which is inside the silverlight project, I would like to access an xml file i.e. test.xml
Which is also inside the silverlight project.
How can I do this please?
Thanks
|
|
|
|
|
Through the code behing you can[^].
I dont think the XAML is powerful enough to load an xml file in SIlverlight.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
While the title is somewhat generic I would love to disucss this as a beginner with experienced MVVM users and other beginners as well.
I have created a WPF app mostly ignoring MVVM, at least to begin with. I have now decided to refactor it and use MVVM. I'm hoping to make it better and easier to manage. However there are several things I'm not 100% certain about how to implement some things in MVVM. I guess there isn't just one way but I would love to hear what you like to do and how. I'm adding numbered discussion points here to better catagorize. If others have questions or thoughts to add please be welcome.
1) Most MVVM examples are quite simple. In reality it can be quite different. For example I often have objects that include a number of other objects which also include other objects. So there is a View where users could choose an object from a list, see detailed info about it and also a list of objects that are it's children. They could then choose a child object and get detailed info about it as well.
How does this apply as ViewModels. Is it a single viewmodel that includes everything, or a viewmodel that opens another different viewmodel. I would like to have the child object as it's own ViewModel/UserControl - View and have the parent able to show this UserControl within it's own.
Would you rather have the child inside the parents viewmodel or seperate but linked?
Can you point out examples or books that investigates this?
2) iEditableObject, I've used this interface on my objects and it works with CollectionViews. I haven't really seen it mention in MVVM. It means a object can basically be in a EditMode and you can rollback changes made and such. Now in my program when you look at the details of a object they are static, meaning you can't change text (it's textBlocks not TextBox), then you press a EDIT button and you get the edit look. I've done this by switching out the dataTemplate for the object. However that seems to mean logic inside Xaml. I guess I could do it in code, or just have seperate UserControls and swithc them out
Also this handles well adding new items to collections but I haven't seen this used in any MVVM example I've seen. Could you point out any?
3) If many apps are getting the data from the same place, and they can change that data. How do you keep the data current. Do you reload it regulary, use ActiveRecord pattern. I guess this has nothing to do with MVVM but I'm fishing out what people have used alongwith MVVM with good results.
4) Can you use LINQ entity items with any good results, like perhaps populating the viewmodel with them? It's not proper to keep the context open but having the object itself might help with saving back to database. What happens to a LINQ object when the Context is closed. Do I still have access to it's relative tables an such.
5) I'm very often showing objects as lists+details for the selected object (master detail view). However the details between objects can be somewhat different. I guess I could make a abstract ViewModel for their common functionality but what about the Views themselves. It will have the same buttons, the same format showing the list and then the details. Basicly the only difference will be the fields in the detail. I can't make a abstract UserControl (except without the XAML). How to solve this? Using styles, ControlTemplates? Again any examples out there I could check out?
I'll probably have million other questions but this is enough for now. If anyone can answer or just point towards something with good answers/examples I would be very happy.
Most of what I know about MVVM comes from http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
|
|
|
|
|
IngoVals wrote: 4) Can you use LINQ entity items with any good results, like perhaps populating the viewmodel with them? It's not proper to keep the context open but having the object itself might help with saving back to database. What happens to a LINQ object when the Context is closed. Do I still have access to it's relative tables an such.
IngoVals wrote: 4) Can you use LINQ entity items with any good results, like perhaps populating the viewmodel with them? It's not proper to keep the context open but having the object itself might help with saving back to database. What happens to a LINQ object when the Context is closed. Do I still have access to it's relative tables an such.
Those are a lot of good questions.
I can only try and share some of my experiences with you. To be honest, I myself would not know if my approaches to these whatever problems I faced were correct or not in the first place.
IngoVals wrote: Would you rather have the child inside the parents viewmodel or seperate but linked?
Keep them separate but linked.
IngoVals wrote: 3) If many apps are getting the data from the same place, and they can change that data. How do you keep the data current. Do you reload it regulary, use ActiveRecord pattern. I guess this has nothing to do with MVVM but I'm fishing out what people have used alongwith MVVM with good results.
You would need some sort of notification mechanism to let all your clients know data has changed. One way could be to use a duplex polling WCF service. Another way could be to use sockets (In case you are not using WCF).
IngoVals wrote: 4) Can you use LINQ entity items with any good results, like perhaps populating the viewmodel with them? It's not proper to keep the context open but having the object itself might help with saving back to database. What happens to a LINQ object when the Context is closed. Do I still have access to it's relative tables an such.
Yes you can. Perhaps someone else here has a better answer to the remaining part of the question.
IngoVals wrote: very often showing objects as lists+details for the selected object (master detail view). However the details between objects can be somewhat different. I guess I could make a abstract ViewModel for their common functionality but what about the Views themselves. It will have the same buttons, the same format showing the list and then the details. Basicly the only difference will be the fields in the detail. I can't make a abstract UserControl (except without the XAML). How to solve this? Using styles, ControlTemplates? Again any examples out there I could check out?
IMO, Keep the views separate.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
Just a heads up from *personal* experience. If you wrote a WPF app without using MVVM, if your project has reached any size at all, its not worth the effort to go MVVM. Non MVVM -> MVVM conversion is usually a complete re-write / re-design. The MFC / Winforms way of doing things is just such a different thought process. Not saying it can't be done, but if you've gone past a couple of views, its pretty much a re-write .
|
|
|
|
|
1. This seems to me that you think of view models as being representations of entities. While in a lot of cases, you will indeed find such correlation, I prefer to think of viewmodels as representations that describe what the view looks like. Having said that, there's nothing wrong with viewmodels that have other viewmodels as properties. In the end, a viewmodel is just an object implementing INotifyPropertyChanged and coupled to xaml via binding.
The structure of your view/model can be (should be?) reflected by the other.
A viewmodel customer can thus have a collection "invoices" while each invoice has a collection "invoiceDetails".
In the xaml, you'ld bind that customer object to the datacontext of a customer control (or grid or whatever you use to represent your customer). Inside that control, you could have an itemscontrol for example to wich you bind the invoices and on that itemscontrol another itemscontrol to bind the details.
There's also nothing wrong with binding the invoices to a combobox for example and only fetching the details of that invoice once it is selected to show that in another itemscontrol etc etc.
In short: it would kinda depend on your user interface.
2. I have never uses iEditableIObject, but have implemented similar systems myself to find out if a viewmodel is "dirty". An undo would (in that system) result in a reload of the dirty object. Perhaps I reïnvented the wheel there, I dunno. It worked fine and clean though.
3. As said allready, you could use WCF polling for this. Usually though, this really isn't done unless there are specific requirements that need such a feature. Unless you plan on caching the whole database, each request would be a new business call, so the data will always be reloaded from the database anyway - giving you the "last version" every call.
4. Personally, I'm not a fan of linq entities, but to each his own. One thing that isn't really personal though is that you should try to keep business entities inside your business layer. Business entities should never leave your business. Use DTO's instead. You can use these dto's binding if all you need to do is show the information on screen. Mostly, you'll want to initisialise viewmodels from these dto's instead.
5. There are dozens of ways to accomplish this, all of wich require some coding. There's no generic way of doing this as far as I know. Me, I'ld probably create a template (or even control if usefull) for each type of detail and show the correct one based on some property in the viewmodel detailing the type that should be used (through binding).
I hope that was somewhat helpfull.
|
|
|
|
|
Hi
I wonder how to open/start a WPF Application from within an Excel Add-In, e.g. if I click a shape on a worksheet the WPF Application (i.e. the main window) should open to allow users to manipulate data based on the worksheet.
If I simply try to open a WPF application from my Excel-Addin like that:
Dim wpfApp as Application = New MyWpfApplication.Application
wpfApp.Run()
there is a message saying that not more than one System.Windows.Application instance can be hosted within one AppDomain.
Is there any possibility to run a WPF App from Excel-Addin and passing arguments (like caller information)?
Is there a lean way to integrate WPF functionality (e.g. a chart generator) in Excel (e.g. via Excel-Addin)? (I know about hosting WPF controls in WinForms controls).
I'm quite experienced with Excel programming but not (yet) in terms of WPF/.net.
Thanks in advance
Marc
-------------------------------
Visual Studio 2010 Ultimate
Microsoft Office 2010
Windows 7 (64bit)
|
|
|
|
|
I have 2 styles. One targeting a ToggleButton and one targeting a checkbox. However when I run the application, if I click one, both change. I've pasted my code, I'm totally stuck.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Window.Resources>
<LinearGradientBrush x:Key="Button_Pill_Selected_Background" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFC6D3D9" Offset="0"/>
<GradientStop Color="#FFE1E7EB" Offset="0.991"/>
<GradientStop Color="#FFCFD9DF" Offset="0.467"/>
<GradientStop Color="#FFE1E7EB" Offset="0.556"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="Button_Pill_Selected_BorderBrush" Color="#FF415469"/>
<LinearGradientBrush x:Key="Button_Pill_Unselected_Background" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#FFD5DEE8" Offset="0.991"/>
<GradientStop Color="White" Offset="0.461"/>
<GradientStop Color="#FFE3E8EF" Offset="0.556"/>
</LinearGradientBrush>
<Style x:Key="ZoomToggleButtonStyle" TargetType="CheckBox">
<Setter Property="Template" x:Name="zoomTemplate">
<Setter.Value>
<ControlTemplate TargetType="CheckBox" x:Name="zomtemplate">
<Grid x:Name="zoomToggleButton">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Indeterminate"/>
<VisualState x:Name="Checked">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFC6D3D9"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFCFD9DF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.467"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFD5DEE8"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE3E8EF"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.461"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFC6D3D9"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFCFD9DF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.467"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomLeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFD5DEE8"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE3E8EF"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.461"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="zoomRightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<StackPanel Orientation="Horizontal">
<Border x:Name="zoomLeftSide" BorderBrush="{StaticResource Button_Pill_Selected_BorderBrush}" BorderThickness="1" CornerRadius="12,0,0,12" Background="{StaticResource Button_Pill_Selected_Background}" Height="24" Width="30">
<StackPanel Orientation="Horizontal">
<Image x:Name="ZoomLeftImage" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,3,0,3"/>
</StackPanel>
</Border>
<Border x:Name="zoomRightSide" BorderBrush="#FF415469" BorderThickness="1" CornerRadius="0,12,12,0" Background="{StaticResource Button_Pill_Unselected_Background}" Height="24" Width="30" RenderTransformOrigin="0.5,0.5">
<StackPanel Orientation="Horizontal">
<Image x:Name="ZoomRightImage" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,3,0,3"/>
</StackPanel>
</Border>
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Template" x:Name="panTemplate">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton" x:Name="toggletemplate">
<Grid x:Name="panSelectToggleButton">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Indeterminate"/>
<VisualState x:Name="Checked">
<Storyboard>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFC6D3D9"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFCFD9DF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.467"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFD5DEE8"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE3E8EF"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.461"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFC6D3D9"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFCFD9DF"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE1E7EB"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.467"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LeftSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFD5DEE8"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="White"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<EasingColorKeyFrame KeyTime="00:00:00" Value="#FFE3E8EF"/>
</ColorAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.991"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[2].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.461"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="RightSide" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[3].(GradientStop.Offset)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.556"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<StackPanel Orientation="Horizontal">
<Border x:Name="LeftSide" BorderBrush="{StaticResource Button_Pill_Selected_BorderBrush}" BorderThickness="1" CornerRadius="12,0,0,12" Background="{StaticResource Button_Pill_Selected_Background}" Height="24" Width="75">
<StackPanel Orientation="Horizontal">
<Image x:Name="leftImage" Width="12" Source="" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,3,0,3"/>
<TextBlock Text="Pan" FontFamily="Segoe UI" FontSize="14" Foreground="#FF1B4C85" VerticalAlignment="Center" Margin="5,3,0,3"/>
</StackPanel>
</Border>
<Border x:Name="RightSide" BorderBrush="#FF415469" BorderThickness="1" CornerRadius="0,12,12,0" Background="{StaticResource Button_Pill_Unselected_Background}" Height="24" Width="75" RenderTransformOrigin="0.5,0.5">
<StackPanel Orientation="Horizontal">
<Image x:Name="rightImage" Width="12" Source="" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5,3,0,3"/>
<TextBlock Text="Select" FontFamily="Segoe UI" FontSize="14" Foreground="#FF1B4C85" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,3,0,3"/>
</StackPanel>
</Border>
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="testToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Width" Value="20"/>
<Setter Property="Height" Value="20"/>
</Style>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<StackPanel>
<ToggleButton x:Name="pan" Style="{StaticResource ToggleButtonStyle}" Margin="20,20,20,20" />
<CheckBox x:Name="zoom" Style="{StaticResource ZoomToggleButtonStyle}" Margin="20,20,20,20"/>
<CheckBox Style="{StaticResource testToggleButtonStyle}" x:Name="test" Margin="20,20,20,20"/>
</StackPanel>
</Grid>
</Window>
|
|
|
|
|
My guess of why this may be happening is that CheckBox is a subclass of ToggleButton[^]. Styles targeted at ToggleButton affect all controls for which the condition (control is ToggleButton) is true. This includes CheckBox and RadioButton.
|
|
|
|
|
Thanks for the reply. Actually as it turns out, The virtual statemanger changes the existing values of the current gradient brush for the background. In this case the background is a common gradient between both controls. So when one changes the background property, it in turns updates the common gradient with the new values, and in turn updates the other control. Hope this saves someone else sometime.
|
|
|
|
|
How to sort the items under some node in Silverlight tree view?
Thank you in advance.
Regards,
Goran
|
|
|
|
|
Are you using proper data binding for your tree? Or are you hand inserting items? If you hand inserted, no choice but to rearrange by hand. If you are using data binding, just sort that part of the collection and the UI will auto-magically update.
|
|
|
|
|
I'm manually inserting data, but in WPF this works for me:
if (treeAdditionalInfo.Items.Count != 0)
{
foreach (TreeViewItem subsystemNodeItem in treeAdditionalInfo.Items)
{
foreach (TreeViewItem formNodeItem in subsystemNodeItem.Items)
{
formNodeItem.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Tag",
System.ComponentModel.ListSortDirection.Ascending));
}
}
}
It means, I want to sort the node items by Tag property of items.
I can't see I could do the same in Silverlight. I've tried to find something on internet, but no luck so far.
I appreciate any help.
Thanks.
|
|
|
|
|
breakpoint not hit --> symbols not loaded, but just for one line of code...
VS2010, C#, Silverlight code behind (xxx.xaml.cs)
here's the code:
List<EntityRec> EntityRecList = new List<EntityRec>
(
new EntityRec[]
{
new EntityRec()
{
Name = "Well List 1",
Entity = "Wellbore",
Count = 17,
Description = "This is a random list of wells that contains\r\nseveral unique formations and depths.",
IsPublic = false
},
...
);
But if I create an array of EntityRec with a fixed size and explicitly assign the new EntityRec items, all break points are hit just fine...
Weird...
Cost me about 3 hours to figure that one out
|
|
|
|
|
When you do stuff inline like that, the debugger may not stop where you expect because the MSIL may be quite different .
|
|
|
|
|
Make sure 'Debug Silvelight' option in the web project properties is checked.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|