| How to instantiate PropertyPath for the StoryBoard with the Dependency property in C#? |
|
 |
Index ‹ Visual Studio 2008 ‹ Windows Presentation Foundation (WPF)
|
- Previous
- 1
- Windows Presentation Foundation (WPF) Proper design for custom templated parent/child control?
Hi everyone, I'm looking for some pointers on building a custom control. I'm doing this as an exercise in learning WPF. Basically here are my requirements:
1) Will have a parent control (ParentControl class) that has a specific Type of child items (ChildPane class). 2) The ParentControl class needs to host the child panes in a certain area. Then it might also have a header area. 3) Only one ChildPane will be visible at a time in the ParentControl. 4) The ChildPane class should be capable of hosting custom content. 5) Both controls need global default styles/templates to be set. 6) For each control, the end user should be able to set a style/template that overrides the global default set up by me for both controls. 7) The end user should be able to set a style/template on a specific ParentControl instance that overrides any global default style/template for ParentControl. 8) The end user should be able to set a style/template on a specific ParentControl instance that overrides the global default style/template for the ChildPane objects displayed in the ParentControl. 9) The end user should be able to set a style/template on a specific ChildPane instance that overrides both the global default style/template for ChildPane AND the style/template, if any, that is set on the "parent" ParentControl for its ChildPanes.
Usage should be simple like this:
<controls:ParentControl> <controls:ChildPane>Pane #1</controls:ChildPane> <controls:ChildPane>Pane #2</controls:ChildPane> <controls:ChildPane>Pane #3</controls:ChildPane> </controls:ParentControl>
Does anyone have any recommendations on getting this sort of functionality working, like a sample that is already out in the wild I've seen samples that do some of this but not all of it.
Also, these are preferred... 1) The parent control's Items collection only return ChildPane types so no casting is needed for the end user. 2) The SelectedPane property should get/set a ChildPane and update UI appropriate when set.
I am considering using Selector as a base class for the ParentControl but that will mean that my Items will be generic and I would prefer them not to be. I am considering ContentControl as my ChildPane base class.
Any help or sample code for the design principles above to get me started is appreciated.
- 2
- Visual Studio Tools for Office Excel scrollbars get really small.
Hi there, another ListObject woe I'm afraid.
I've a listobject, I bind it to a System.Windows.Forms.BindingSource which has an array of objects as its datasource. I have a test setup so that when I click a button it changes the array the bindingSource is bound to. So it alternates between an array of size 5, and an array of size 1000 (so if I keep clicking the button the listobject alternates between having 5 rows of data and 1000 rows of data).
However, when it binds to the 1000 rows the scrollbar at the side gets smaller, as you'd expect. When it binds on the next button click to 5 rows the scrollbar stays the same size, thus making it hard to scroll precisely. If I bind to 1000 rows again (another button click) the scrollbar gets even smaller. In fact the more times to bind to the 1000 rows the smaller and smaller it gets, such that if you bind to say 100 rows that needs alittle scrolling its very difficult to do this with any accuracy as the scrollbar by this point is very sensitive.
I can't think why it keeps getting smaller, or find any way of resetting its size. I've tried deleting all rows from the bottom of the listobject to the bottom of the Worksheet, but it doesn't change anything.
Strange problem, hope someone might have some idea.
Thanks very much.
- 3
- Visual Studio WPF Designer Cider support for local assembly references?
Am I doing something wrong Or do i possibly have an bad interaction between Cider and ReSharper (my guess).
every time i make a reference to the local namespace in the same assembly... e.g.
< Page x:Class="MyNameSpace.TestPage" xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local="clr-namespace:MyNameSpace" Title="TestPage"> <Page.Resources> <local:MyConverter x:Key="myConverter"/>
I end up getting all sorts of errors, even though it all compiles fine. In just the snippet i've pasted here, I get three errors:
Assembly '' was not found. The 'clr-namespace' URI refers to an assembly that is not referenced by the project.
The Element Page.Resources... has invalid child element MyConverter..."
and The type 'local:MyConverter' was not found. Verify you are not missing an assembly reference."
Ditto on the code behind... InitializeComponent() is not found, nor are any references to named xaml elements. but again, everything compiles and runs just fine. Is this just a preview issue Or are Orcas and Resharper fighting
- 4
- 5
- Windows Presentation Foundation (WPF) XMLDataProvider and node subitem Databinding question
Hi,
My client have a XML data source containing a list of elements' records;
any record contains multiple fields which will bound to a listview;
one of the fields contains a sub XML structure which represents the Details of one record.
To avoid any discussions, I can't change the data structure...
The goal is to display the list of records into a Grid or Listview and when a record is selected,
to display the XML details into a Treeview in the right of the Grid like a master details form except both are contained by same record.
Anybody can give some hint to do this
Thxs in advance
-Vince
Thxs
-Vince
- 6
- Windows Presentation Foundation (WPF) Listview content Wrap
Is there a way to have the control list items like in a list box but when the bottom of the screen is reached have a new column formed so that all of the content is on the screen I.E. If the screen can hold 40 rows of data and I have 100 rows to display I would end up with three columns of data.
Thanks in advance
- 7
- Visual Studio Extensibility Connector inheritance problem
Hi,
I got problems with connector inheritance (i'm using the RTM bits).
Suppose I start from the Task Flow template.
I add a connector MasterConnector that becomes the base class for the CommentConnector.
When I create an instance of the CommentConnector (I associate a comment to a task), save the diagram and reopen it, the instance of the CommentConnector has doubled (two lines appear instead of one).
Has anybody noticed the same problem
Thanks!
Mike
- 8
- 9
- Visual Studio Extensibility Add a Folder to a project
I am trying to create a folder through IVsProject.AddItem method.
The method documentation says I should pass VSADDITEMOP_OPENDIRECTORY.
This enum does not exist in the SDK.
How do I create a folder in Project Thanks
- 10
- ADO.NET (Pre-release) Using Entity Model in a DLL
I am building a library (dll) which calls my entity model for data requirements. The problem is where to put the configration file. There are two options:
1. Either put the config information in the dll.config file
2. Or Put it in the calling application (App.config)
In both casses it is giving a exception.
When I put the config information in the dll.config file it is giving the following exception:
System.ArgumentException was unhandled Message="The named connection HelloWorldDBConnectionString is either not found in the configuration, it's not intended to be used with the Mapping Provider, or it's invalid.\r\nParameter name: connectionString" Source="System.Data.Entity" ParamName="connectionString" StackTrace: at System.Data.Mapping.MapConnection.ChangeConnectionString(String newConnectionString, String callersConnectionStringParameterName) at System.Data.Mapping.MapConnection..ctor(String connectionString) at System.Data.Objects.ObjectContext.CreateMapConnection(String connectionString, String defaultContainerName) at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) at HelloWorldDBModel.HelloWorldDB..ctor(String connectionString) in f:\EndToEndHelloWorld\ModelObject1\obj\Debug\ModelObject1.Model.cs:line 101 at HelloWorldService.HelloWorldServer.GetMessage() in f:\EndToEndHelloWorld\HelloWorldService\Program.cs:line 17 at LocalServiceTest.Program.Main(String[] args) in F:\EndToEndHelloWorld\LocalServiceTest\Program.cs:line 13 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
When I put the config info in the App.config of the calling exe file it gives the following exception:
System.ArgumentException was unhandled Message="The default entity container name 'HelloWorldDBModel.HelloWorldDB' is invalid. The required mapping and metadata information could not be found.\r\nParameter name: defaultContainerName" Source="System.Data.Entity" ParamName="defaultContainerName" StackTrace: at System.Data.Objects.ObjectContext.CreateMapConnection(String connectionString, String defaultContainerName) at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) at HelloWorldDBModel.HelloWorldDB..ctor(String connectionString) in f:\EndToEndHelloWorld\ModelObject1\obj\Debug\ModelObject1.Model.cs:line 101 at HelloWorldService.HelloWorldServer.GetMessage() in f:\EndToEndHelloWorld\HelloWorldService\Program.cs:line 17 at LocalServiceTest.Program.Main(String[] args) in F:\EndToEndHelloWorld\LocalServiceTest\Program.cs:line 13 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
How do I config the entities in a dll
- 11
- LINQ Project General Cannot insert a subclass if it is really stored in a table associated with its parent
Hi,
I have been enjoying the incredible advances visible in the LINQ May 2006 CTP. I have followed the instructions in the DLink Designer Doc, creating a table Person with a type (discriminator) column for polymorphism. This table is to store not only persons but also employees, which have an additional property for Managers which of course is really a column of the Person table.
The problem appears when I want to insert an Employee. I have created a form with the following partial code:
------------------------
NorthwindDataContext dc = new NorthwindDataContext(); BindingList<Employee> persons; private void Form1_Load(object sender, EventArgs e) { var results = from emp in dc.Persons where emp is Employee select (Employee)emp;
this.persons = results.ToBindingList();
this.employeeBindingSource.DataSource = this.persons; }
private void employeeBindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.dc.SubmitChanges(); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { int largestId = dc.Persons.Max( p => p.ID); Employee emp = this.persons[this.persons.Count-1]; emp.ID = largestId + 1; emp.Type = 2; } -----------------------
No error is given on save but the new employee does not get saved. And of course, it is understandable since the row type is Person not Employee.
this is why it seems to me to be an issue of how to deal with operations on subclasses.
Any light
Best regards,\
Juan Dent
- 12
- Visual Studio Report Controls How to: Add a rtf file to the report?
I'm making a sales contract with the report control, what I want to do is: each time the report is generated, it will import a rtf file ( for terms and conditions ) to the report and show it correctly with the report.
Is there any way I can do this with the report control
Thanks in advacne.
Long
- 13
- Visual J# General read text for a .txt helpI'm attempting to read a line of text from a text file but found no scanner class that I usually use in the java.util package. Does anyone have a good suggestion on what I should use to read a line of text
Thanks
- 14
- Windows Communication Foundation ("Indigo") How do I get WSHttpBinding to work on a clientI can run a WCF client and WCF Service on the same machine using BasicHttpBinding, and I can get the cleint to run on a remote machine.
I take the same code for both client and service and replace BasicHttpBinding with WSHttpBinding, and the Service and client will work on the same machine properly.
However, when I take the cleint (Containing WSHttpBinding) and access the WCF Service (also containing WSHttpBinding) from a REMOTE client, the client fails with the following error:
Unhandled Exception: System.ServiceModel.Security.MessageSecurityException: An u nsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.Fa ultException: An error occurred when verifying security for the message.
How can I get the WCF client containing WSHttpBinding to work properly on a remote client
- 15
|
| Author |
Message |
tuhin sinha

|
Posted: Windows Presentation Foundation (WPF), How to instantiate PropertyPath for the StoryBoard with the Dependency property in C#? |
Top |
Hi All
Below is the Xaml Code which is working as per the need to animate an image. I am tring to animate the same image through C#. Can Someone help in Setting the Storyboard.TargetProperty in C#.
How to instantiate PropertyPath for the StoryBoard with the Dependency property for Image Translate.XProperty in C# as shown below eg. (UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X) which is in XAML.
< Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ccl="clr-namespace:CustomControlLibrary;assembly=CustomControlLibrary"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/interactivedesigner/2006"
mc:Ignorable="d"
Background="#FFFFFFFF"
x:Name="DocumentRoot"
x:Class="Animation.SampleMouseAnimation"
Width="640" Height="480">
< Grid.Resources>
< Storyboard x:Key="OnLoaded">
< DoubleAnimationUsingKeyFrames BeginTime="00:00:01" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)" Storyboard.TargetName="Button">
< SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="370" KeyTime="00:00:00"/>
< SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="11" KeyTime="00:00:10.9580000"/>
</ DoubleAnimationUsingKeyFrames>
< DoubleAnimationUsingKeyFrames BeginTime="00:00:01" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)" Storyboard.TargetName="Button">
< SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="224" KeyTime="00:00:00"/>
< SplineDoubleKeyFrame KeySpline="0.5,0.5,0.5,0.5" Value="19" KeyTime="00:00:10.9580000"/>
</ DoubleAnimationUsingKeyFrames>
</ Storyboard>
</ Grid.Resources>
< Grid.Triggers>
< EventTrigger RoutedEvent="FrameworkElement.Loaded">
< BeginStoryboard x:Name="OnLoaded_BeginStoryboard" Storyboard="{DynamicResource OnLoaded}"/>
</ EventTrigger>
</ Grid.Triggers>
< Grid.ColumnDefinitions>
< ColumnDefinition/>
</ Grid.ColumnDefinitions>
< Grid.RowDefinitions>
< RowDefinition Height="*"/>
</ Grid.RowDefinitions>
< Image HorizontalAlignment="Left" VerticalAlignment="Top" Margin="89,107,0,0" Width="16" Height="31" x:Name="Button" Source="C:\Documents and Settings\tsinha\My Documents\Interactive Designer Projects\UntitledProject1\mouse11.JPG" RenderTransformOrigin="0.5,0.5" Grid.Row="0">
< Image.RenderTransform>
< TransformGroup>
< TranslateTransform X="0" Y="0"/>
</ TransformGroup>
</ Image.RenderTransform>
</ Image>
</ Grid>
C# Code:
using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
namespace Animation
{
public partial class Sample:Page
{
private string _targetName = "mouseImage";
private string _xtargetProperty = "(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.X)";
private string _ytargetProperty = "(UIElement.RenderTransform).(TransformGroup.Children)[0].(TranslateTransform.Y)";
private double _xBeginTime = 5;
public string TargetName
{
get { return _targetName; }
set { _targetName = value; }
}
public string XTargetProperty
{
get { return _xtargetProperty; }
set { _xtargetProperty = value; }
}
public string YTargetProperty
{
get { return _ytargetProperty; }
set { _ytargetProperty = value; }
}
public Image mouseImage;
public Sample()
{
mouseImage = new Image();
mouseImage.HorizontalAlignment = HorizontalAlignment.Left;
mouseImage.VerticalAlignment = VerticalAlignment.Top;
mouseImage.Margin = new Thickness(89, 107, 0, 0);
mouseImage.Width = 16;
mouseImage.Height = 31;
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri("C:\\Documents and Settings\\tsinha\\My Documents\\Interactive Designer Projects\\UntitledProject1\\mouse11.JPG");
bitmap.EndInit();
mouseImage.Source = bitmap;
mouseImage.RenderTransformOrigin = new Point(0.5, 0.5);
TransformGroup imgTransformGroup = new TransformGroup();
TranslateTransform tt = new TranslateTransform(0,0);
imgTransformGroup.Children.Add(tt);
mouseImage.RenderTransform = imgTransformGroup;
mouseImage.Name = TargetName;
// Create a name scope for the page.
NameScope.SetNameScope(this, new NameScope());
this.RegisterName(TargetName, mouseImage);
DoubleAnimationUsingKeyFrames xDoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
xDoubleAnimationUsingKeyFrames.BeginTime = TimeSpan.FromMilliseconds(_xBeginTime);
SplineDoubleKeyFrame xSplineDoubleKeyFrame1 = new SplineDoubleKeyFrame();
xSplineDoubleKeyFrame1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0));
KeySpline xKeySpline1 = new KeySpline(0.5, 0.5, 0.5, 0.5);
xSplineDoubleKeyFrame1.KeySpline = xKeySpline1;
xSplineDoubleKeyFrame1.Value = 370;
SplineDoubleKeyFrame xSplineDoubleKeyFrame2 = new SplineDoubleKeyFrame();
xSplineDoubleKeyFrame2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10.9580000));
KeySpline xKeySpline2 = new KeySpline(0.5, 0.5, 0.5, 0.5);
xSplineDoubleKeyFrame2.KeySpline = xKeySpline2;
xSplineDoubleKeyFrame2.Value = 11;
xDoubleAnimationUsingKeyFrames.KeyFrames.Add(xSplineDoubleKeyFrame1);
xDoubleAnimationUsingKeyFrames.KeyFrames.Add(xSplineDoubleKeyFrame2);
//Y Co-ordinate
DoubleAnimationUsingKeyFrames yDoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
yDoubleAnimationUsingKeyFrames.BeginTime = TimeSpan.FromMilliseconds(_xBeginTime);
SplineDoubleKeyFrame ySplineDoubleKeyFrame1 = new SplineDoubleKeyFrame();
ySplineDoubleKeyFrame1.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(0));
KeySpline yKeySpline1 = new KeySpline(0.5, 0.5, 0.5, 0.5);
ySplineDoubleKeyFrame1.KeySpline = xKeySpline1;
ySplineDoubleKeyFrame1.Value = 224;
SplineDoubleKeyFrame ySplineDoubleKeyFrame2 = new SplineDoubleKeyFrame();
ySplineDoubleKeyFrame2.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(10.9580000));
KeySpline yKeySpline2 = new KeySpline(0.5, 0.5, 0.5, 0.5);
ySplineDoubleKeyFrame2.KeySpline = xKeySpline2;
ySplineDoubleKeyFrame2.Value = 19;
yDoubleAnimationUsingKeyFrames.KeyFrames.Add(ySplineDoubleKeyFrame1);
yDoubleAnimationUsingKeyFrames.KeyFrames.Add(ySplineDoubleKeyFrame2);
// Create a name scope for the page.
NameScope.SetNameScope(this, new NameScope());
Storyboard.SetTargetProperty(xDoubleAnimationUsingKeyFrames, new PropertyPath(TranslateTransform.XProperty));
Storyboard.SetTargetName(yDoubleAnimationUsingKeyFrames, TargetName);
Storyboard.SetTargetProperty(yDoubleAnimationUsingKeyFrames, new PropertyPath(TranslateTransform.YProperty));
Storyboard mouseImageStoryboard = new Storyboard();
//mouseImageStoryboard.Children.Add(myDoubleAnimation);
mouseImageStoryboard.Children.Add(xDoubleAnimationUsingKeyFrames);
mouseImageStoryboard.Children.Add(yDoubleAnimationUsingKeyFrames);
ResourceDictionary resourceStoryBoard = new ResourceDictionary();
resourceStoryBoard.Add( "mouseImageStoryboard", mouseImageStoryboard);
Grid grid = new Grid();
grid.Width = 640 ;
grid.Height = 480;
grid.Resources = resourceStoryBoard;
ColumnDefinition col = new ColumnDefinition();
grid.ColumnDefinitions.Add(col);
RowDefinition row = new RowDefinition();
row.Height = GridLength.Auto;
grid.RowDefinitions.Add(row);
Grid.SetRow(mouseImage, 0);
BeginStoryboard beginStoryboard = new BeginStoryboard();
beginStoryboard.Storyboard = mouseImageStoryboard;
EventTrigger mouseImageTrigger = new EventTrigger();
mouseImageTrigger.RoutedEvent = Image.LoadedEvent;
mouseImageTrigger.Actions.Add(beginStoryboard);
grid.Triggers.Add(mouseImageTrigger);
grid.Children.Add(mouseImage);
this.Content = grid;
this.Loaded += delegate(object sender, RoutedEventArgs args)
{
mouseImageStoryboard.Begin(mouseImage);
};
}
}
}
Tuhin
Visual Studio 200833
|
| |
|
| |
 |
mactacular

|
Posted: Windows Presentation Foundation (WPF), How to instantiate PropertyPath for the StoryBoard with the Dependency property in C#? |
Top |
Hi Tuhin,
Try changing your sample.cs similar to the code below.
HTH
using System; using System.IO; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Navigation; using System.Windows.Media.Imaging; using System.Windows.Shapes;
using System.ComponentModel;
namespace Animation { public partial class Sample:Page {
private string _targetName = "mouseImage"; private double _xBeginTime = 5;
public string TargetName { get { return _targetName; } set { _targetName = value; } }
public Image mouseImage;
public Sample() { mouseImage = new Image(); mouseImage.HorizontalAlignment = HorizontalAlignment.Left; mouseImage.VerticalAlignment = VerticalAlignment.Top; mouseImage.Margin = new Thickness(89, 107, 0, 0); mouseImage.Width = 16; mouseImage.Height = 31; BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(@"C:\Documents and Settings\tsinha\My Documents\Interactive Designer Projects\UntitledProject1\mouse11.JPG",UriKind.Absolute); bitmap.EndInit(); mouseImage.Source = bitmap; mouseImage.RenderTransformOrigin = new Point(0.5, 0.5); Rectangle myRectangle = new Rectangle(); myRectangle.Name = "MyRectangle2";
Grid grid = new Grid(); grid.Width = 640 ; grid.Height = 480;
ColumnDefinition col = new ColumnDefinition(); grid.ColumnDefinitions.Add(col);
RowDefinition row = new RowDefinition(); row.Height = GridLength.Auto; grid.RowDefinitions.Add(row); Grid.SetRow(mouseImage, 0); grid.Children.Add(mouseImage); this.Content = grid;
TransformGroup imgTransformGroup = new TransformGroup(); TranslateTransform tt = new TranslateTransform(); imgTransformGroup.Children.Add(tt); mouseImage.RenderTransform = imgTransformGroup; mouseImage.Name = TargetName;
NameScope.SetNameScope(this, new NameScope()); this.RegisterName("tt", tt); this.RegisterName(TargetName, mouseImage);
DoubleAnimationUsingKeyFrames xDoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); xDoubleAnimationUsingKeyFrames.BeginTime = TimeSpan.FromMilliseconds(_xBeginTime);
SplineDoubleKeyFrame xSplineDoubleKeyFrame1 = new SplineDoubleKeyFrame(110, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5)), new KeySpline(0.5, 0.5, 0.5, 0.5)); SplineDoubleKeyFrame xSplineDoubleKeyFrame2 = new SplineDoubleKeyFrame(370, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(10.9580000)), new KeySpline(0.5, 0.5, 0.5, 0.5));
xDoubleAnimationUsingKeyFrames.KeyFrames.Add(xSplineDoubleKeyFrame1); xDoubleAnimationUsingKeyFrames.KeyFrames.Add(xSplineDoubleKeyFrame2);
//Y Co-ordinate DoubleAnimationUsingKeyFrames yDoubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames(); yDoubleAnimationUsingKeyFrames.BeginTime = TimeSpan.FromMilliseconds(_xBeginTime);
SplineDoubleKeyFrame ySplineDoubleKeyFrame1 = new SplineDoubleKeyFrame(19, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(5)), new KeySpline(0.5, 0.5, 0.5, 0.5)); SplineDoubleKeyFrame ySplineDoubleKeyFrame2 = new SplineDoubleKeyFrame(224, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(10.9580000)), new KeySpline(0.5, 0.5, 0.5, 0.5));
yDoubleAnimationUsingKeyFrames.KeyFrames.Add(ySplineDoubleKeyFrame1); yDoubleAnimationUsingKeyFrames.KeyFrames.Add(ySplineDoubleKeyFrame2); Storyboard.SetTargetName(xDoubleAnimationUsingKeyFrames, "tt"); Storyboard.SetTargetProperty(xDoubleAnimationUsingKeyFrames, new PropertyPath(TranslateTransform.XProperty));
Storyboard.SetTargetName(yDoubleAnimationUsingKeyFrames, "tt"); Storyboard.SetTargetProperty(yDoubleAnimationUsingKeyFrames, new PropertyPath(TranslateTransform.YProperty)); Storyboard mouseImageStoryboard = new Storyboard();
mouseImageStoryboard.Children.Add(xDoubleAnimationUsingKeyFrames); mouseImageStoryboard.Children.Add(yDoubleAnimationUsingKeyFrames);
this.Loaded += delegate(object sender, RoutedEventArgs args) {
mouseImageStoryboard.Begin(this); };
} } }
|
| |
|
| |
 |
| |
 |
Index ‹ Visual Studio 2008 ‹ Windows Presentation Foundation (WPF) |
- Next
- 1
- LINQ Project General Insert image with dlinq
I want to do the following
var qry =
from c in db.Customer
select c;
foreach (var cust in qry)
{
cust.Photo = pictureBox1.Image;// won't compile why
};
isn't this the way it should work
cust.Photo.PropertyType = System.Byte[]
cust.ServerType = image
- 2
- 3
- Visual Studio Extensibility Enterprise Library
Has anyone used Enterprise Library in their VSPackage implementations I'm trying to use the Exception Handling Block, but having some difficulties, since the actual application is devenv.exe.
Thanks,
Mike
- 4
- Visual Studio Extensibility VS local variables extensible? Blocking issueHi,
I added an option in the context menu when you right-click on a local variable while debugging.
Now I can't figure out how to get the currently selected variable (ie variable right-clicked on). The local variable list do not seam to work with IVsMonitorSelection and IVsSelectionEvents. I also tried with the DTE which exposes the local variables but it has no information on what is selected. The debugger API do not allow me to obtain this information either as far as my research went.
Finally, with spy++ I can find the hwnd of the list which is of type TREEGRID with no child windows. Can you provide any information on how to access the treegrid information or another way to get the currently selected local variable
This is a blocking issue for me.
Thanks Charles Verdon
- 5
- 6
- Visual Studio MSBuild More info on sgen.exe and why it fails.
I am trying to build a project in VS 2005 but I am getting the error:
Error 67 "sgen.exe" exited with code 1. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets 1892 9 TAI.Util
This project had been building just fine earlier today. The only thing that happened between is I refreshed the web references in this project. As a test I added the same web references to a new project and it builds just fine.
- 7
- Windows Communication Foundation ("Indigo") Using the Hands-On labs with September CTP
Ok I figured out a few of the things I needed to change to make the InterceptorBinding code work in the advanced WCF hands on lab that initially targeted the June CTP. What I'm not able to figure out is this change to no longer use the "InnerChannelListener" from the ChannelListenerBase. I've found a handful of postings on using "GetProperty" to do it but I have not been able to implement it. This is confusing me a little, can someone explain this Below is my code for the InnerChannelListener property that does not like my setter because it's not setting an actual variable:
public IChannelListener<TChannel> InnerChannelListener {
get { return (IChannelListener<TChannel>)base.GetProperty<TChannel>() ; }
set { (IChannelListener<TChannel>)base.GetProperty<TChannel>() = value; }
}
- 8
- Visual Studio MSBuild Compile Release Config using MSBuild from Web Application
I am trying to use MSBuild from within ASP.NET code to compile a project using the Release Configuration. Doing so logs the following in my log file. When I executed the same code without trying to change the Configuration I had no problem.
Build started 10/30/2006 6:20:57 PM. __________________________________________________ Project "C:\Documents and Settings\joness\My Documents\Visual Studio 2005\Projects\ClassLibrary1\ClassLibrary1.sln" (default targets):
Target ValidateSolutionConfiguration: Building solution configuration "Release|Any CPU". Target Build: Target ClassLibrary1: __________________________________________________ Project "C:\Documents and Settings\joness\My Documents\Visual Studio 2005\Projects\ClassLibrary1\ClassLibrary1.sln" is building "C:\Documents and Settings\joness\My Documents\Visual Studio 2005\Projects\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj" (default targets):
Target CoreCompile: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:TRACE /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug:pdbonly /optimize+ /out:obj\Release\ClassLibrary1.dll /target:library Class1.cs Properties\AssemblyInfo.cs CSC : fatal error CS0007: Unexpected common language runtime initialization error -- 'Class not registered ' Done building target "CoreCompile" in project "ClassLibrary1.csproj" -- FAILED.
Done building project "ClassLibrary1.csproj" -- FAILED.
Build FAILED. CSC : fatal error CS0007: Unexpected common language runtime initialization error -- 'Class not registered ' 0 Warning(s) 1 Error(s)
Time Elapsed 00:00:00.09
The code that I am using (right now, I've tried many things) is:
Microsoft.Build.BuildEngine.Engine msBuild; Microsoft.Build.BuildEngine.FileLogger logger;
msBuild = new Microsoft.Build.BuildEngine.Engine(); msBuild.BinPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
logger = new Microsoft.Build.BuildEngine.FileLogger(); logger.Parameters = @"logfile=C:\build.log"; msBuild.RegisterLogger(logger); msBuild.OnlyLogCriticalEvents = false;
Microsoft.Build.BuildEngine.Project project = new Microsoft.Build.BuildEngine.Project(msBuild); project.Load(projToCompile);
foreach (Microsoft.Build.BuildEngine.BuildPropertyGroup pg in project.PropertyGroups) { pg.AddNewProperty("Configuration", "Release"); }
result = msBuild.BuildProject(project); msBuild.UnregisterAllLoggers();
- 9
- Windows Presentation Foundation (WPF) Binding problem after selection on ListView
I have created a binding style1 which binds SelectedItem to a DependencyProperty and is programmatically applied to a control.
If a style is applied to a control before making selection the binding works, but if a selection is made first and style is applied after that the selection binding will not work...
Is that a bug.. or am I missing something (Try this code and see if you hit the breakpoint)
< Window x:Class="BorkenBindingAfterStyleSwitch.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BorkenBindingAfterStyleSwitch" Height="395" Width="499"
Name="root">
< Grid>
< Button Height="31" HorizontalAlignment="Right" Margin="0,29,28,0" Name="button1" VerticalAlignment="Top" Width="129" Click="ShowStyle1">style1</Button>
< Button Height="31" HorizontalAlignment="Right" Margin="0,71,28,0" VerticalAlignment="Top" Width="129" Click="ShowStyle2">style2</Button>
< ListView Height="96" Margin="21,22,0,0" Name="listView1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="120">
< TextBlock Text="string1"/>
< TextBlock Text="string2"/>
</ ListView>
</Grid>
</ Window>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
}
public static readonly DependencyProperty SelectionProperty =
DependencyProperty.Register("Selection",
typeof(object),
typeof(Window1),
new FrameworkPropertyMetadata(null, new PropertyChangedCallback(Callback)));
public object Selection
{
get { return (object)GetValue(SelectionProperty); }
set { SetValue(SelectionProperty, value); }
}
private static void Callback(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
// property changed
// SET BREAKPOINT HERE
}
private void ShowStyle1(object sender, RoutedEventArgs e)
{
this.listView1.Style = Application.Current.FindResource("style1") as Style;
}
private void ShowStyle2(object sender, RoutedEventArgs e)
{
this.listView1.Style = Application.Current.FindResource("style2") as Style;
}
}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
< Application x:Class="BorkenBindingAfterStyleSwitch.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
< Application.Resources>
< Style x:Key="style1" TargetType ="{x:Type ListView}">
< Setter Property="SelectedItem" Value="{Binding Selection, ElementName=root}"/>
< Setter Property="Background" Value="green"/>
</ Style>
< Style x:Key="style2" TargetType ="{x:Type ListView}">
< Setter Property="SelectedItem" Value="{x:Null}"/>
< Setter Property="Background" Value="yellow"/>
</ Style>
</ Application.Resources>
</Application>
- 10
- Windows Presentation Foundation (WPF) Corrupt Back Buffer?
I have a fairly complex app that suddenly has been displaying what looks like a corrupt back buffer... as if the backing store for the window is confused about it's size or something.
When the app starts everything looks fine, but whenever i mouse over any control that changes state on mouse over, the whole rest of the window gets corrupted with what looks like the right image render with the wrong "width" if you know what i mean.
There are no errors in the debug output while this happens...
Here's what it looks like before I mouse over the button:
http://i126.photobucket.com/albums/p110/xamlgeek/notcorrupt.png
And here what it looks like after:
http://i126.photobucket.com/albums/p110/xamlgeek/corrupt.png
Is this a driver issue And if so, why did it just start happening today after months of never seeing it. I have refactored a bunch of my code, but done nothing really new or trickier...
This is on Windows XP Pro SP2, Dell D-820 laptop, RC1 WPF bits, NVidia Quadro NVS 120M
- 11
- Visual Studio Source Control and SourceSafe VS2005 and Source Safe BindingI am converting many cpp projects from VC6 to VC8 and am having problems with Source Safe binding in VS2005.
I have a working structure like this: d:\common\ com\ project1\ project2\ project3\ include\ project4\ include\
In VC6, I could have project1 open, and add a header file that is found in common\include and still have source control over that file while working in VC6. Now that I have moved to VC8, I try to add a header file from common\include\ to project1, and it gives me an error message stating: Some of the files you are adding to your project are located outside of the project's binding root. These files cannot be source controlled unless they are moved.
If the project's hierarchy on disk mimics the hierarchy in the source control database, you might be able to control these files by changing the project's bindings. For more information on how to do this, click Help.
I cannot seem to bind source safe to common\, and i cannot add a file to the source control. Is there a way to ensure that you will have source control over a file that is not located within the project's directory
- 12
- Visual Studio Tools for Office How to associate an icon with a Message Class to display in folder views (VSTO 2005 SE + C#)?
I am currently writing an add-in for Outlook 2007 with VSTO 2005 SE.
I have used a form region with a formRegionType of replaceAll which is associated in the registry to the message class IPM.Post.MyPost. My add-in works as expected with a compose and a read form.
I am in the stage of polishing the GUI with icons and proper ribbons. One requirement is to display the folder items with one of two icons depending on item status.
My initial thought was to define the <icons> in the form region manifest but it does not seem to have any effect.
< xml version="1.0" encoding="utf-8" > <FormRegion xmlns="http://schemas.microsoft.com/office/outlook/12/formregion.xsd"> ... <icons> <default>icon.png</default> <read>icon.png</read> <unread>icon.png</unread> <window>icon.png</window> </icons> </FormRegion>
Note that there is no custom form. In tehse circumstances, what is the proper way to achieve the above
Thank you for your help.
- 13
- Visual Studio Tools for Office Assembly * cound not be found
Hi All,
I just installed VSTO SE (last version), and created WordAddIn , and just compiled, it give me three Error
Error 1: The type or namespace name 'AddIn' does not exist in the namespace 'Microsoft.Office.Tools' (are you missing an assembly reference ) C:\code\WordAddIn4\WordAddIn4\ThisAddIn.Designer.cs 19 68 WordAddIn4
Error 2: The type or namespace name 'IStartup' does not exist in the namespace 'Microsoft.VisualStudio.Tools.Applications.Runtime' (are you missing an assembly reference ) C:\code\WordAddIn4\WordAddIn4\ThisAddIn.Designer.cs 19 125 WordAddIn4
Error 3: The type or namespace name 'ICachedDataProvider' does not exist in the namespace 'Microsoft.VisualStudio.Tools.Applications.Runtime' (are you missing an assembly reference ) C:\code\WordAddIn4\WordAddIn4\ThisAddIn.Designer.cs 31 67 WordAddIn4
I add many different Assembly include those one in GAC , Office12 .... is still i me getting this Error
Any help Apperciate in advance! -:)
Reza
- 14
- 15
- Windows Presentation Foundation (WPF) Unit Testing with WPF + MVP
Hi,
I'm trying to suss out the best way to unit test presenters with WPF views in a multithreading scenario. This is easiest to explain via code. Here's a view interface:
public interface ISearchView { Dispatcher Dispatcher { get; }
SearchCriteria SearchCriteria { set; }
SearchResults SearchResults { set; }
event EventHandler<EventArgs> PerformSearch; }
The implementation of this interface is a WPF user control that binds various child controls to the search criteria to enable the user to edit the criteria prior to searching. The PerformSearch event is raised whenever the user clicks the search button. The Dispatcher property gets the view's dispatcher so the presenter can pass results back to it safely.
The presenter code looks something like this:
public class SearchPresenter { private readonly ISearchView _view; private readonly SearchCriteria _searchCriteria;
public SearchPresenter(ISearchView view) { _searchCriteria = new SearchCriteria(); _view = view; _view.SearchCriteria = _searchCriteria; _view.PerformSearch += View_PerformSearch; }
private void ViewPerformSearch(object sender, EventArgs e) { DoSearch(); }
private void DoSearch() { _view.Results = null;
ThreadPool.QueueUserWorkItem(delegate { //search logic is here - it might take a while to execute
//search is finished - assign results to view _view.Dispatcher.Invoke(DispatcherPriority.Send, new AssignHandler(Assign), results); }); } }
This all works fine and the beauty is that the view has no idea that the search is taking place on a separate thread. It doesn't need to know. We could change the presenter so that it is single-threaded or only switches to a separate thread in certain circumstances and the view would be none the wiser. Also, the view code is kept much simpler as a result.
The problem occurs during unit testing and, specifically, mocking the view's interface. The Dispatcher class is sealed and only has private constructors. The only way to get a Dispatcher is via the static CurrentDispatcher property. This makes it extremely cumbersome and hard, if not impossible, to unit test this code.
I have thought of only a couple of workarounds:
- Put the thread-safety code into the view implementation, and just have the presenter assign the results directly rather than via the dispatcher.
- Define my own IDispatcher interface and two implementations of this interface: DispatcherWrapper and MockDispatcher. DispatcherWrapper would wrap WPF's Dispatcher class and MockDispatcher would be used in unit testing. Views would expose an IDispatcher instead of a Dispatcher.
I don't like option 1 because it complicates the view implementation and requires it to understand the threading context in which it is running. I don't like 2 because, well, it's ugly and requires more work.
Any help much appreciated.
Thanks, Kent Boogaart
|
|
|