|
Hello
I have an interesting problem i require some help with.
I am animating a simple object to follow a path defined by a path geometry. For example i have a myrectangle object which i add to a canvas, i define the path geometry in the myrectangle class and animate a simple ellipse to follow this path. for example one end of the rectangle to the other.
This all works fine IF I DO NOT APPLY TRANSFORMATIONS. If i apply a transformation to the myrectangle object the animation still runs but in the OLD coordinates, the coordinates that are not transformed.
The only solution i have managed to come up with is to create another class myrectanglecontainer that derives from canvas and then add the myrectangle as a child to this object. My preference is to find a better way to do this as i do not want to create a container class for all of my different objects.
Can i create a container class at runtime. ie: remove myrectangle from parent canvas and then add new canvas (with myrectangle as child) to parentcanvas. I tried to do this but got an infinate loop exception.
Any comments welcome
Thanks
|
|
|
|
|
I am writing custom drawing code by overriding the OnRender function of a Canvas window.
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
// bunch of drawing code
}
The window that I'm drawing stretches very far in the vertical direction, so I contain it in a ScrollViewer.
When data changes in the system, I want to redraw just the small portion of the window that represents that data, not the entire window. However, I can't seem to figure out how to invalidate a region of the window. I am currently invalidating, and redrawing the entire window. Help!
Thanks,
Aaron
|
|
|
|
|
Hi Experts,
I have a custom datepicker with me and i am trying to set focus to this using attached property. I have the toolkit version 3.5.50211.1 which was released on Feb 2010. The focus is working fine when i do DatePicker.Focus(); in my code. My custom datepicker code is as follows:
-- My DatePicker
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.ComponentModel;
using System.Windows.Controls.Primitives;
namespace Guardian.PAS.PASFramework.UI.WPF
{
public class PASDatePicker : DatePicker
{
#region Attached Property
public static bool GetIsFocus(DependencyObject obj)
{
return (bool)obj.GetValue(IsFocusProperty);
}
public static void SetIsFocus(DependencyObject obj, bool value)
{
obj.SetValue(IsFocusProperty, value);
}
public static readonly DependencyProperty IsFocusProperty =
DependencyProperty.RegisterAttached(
"IsFocus", typeof(bool), typeof(PASDatePicker),
new UIPropertyMetadata(false, OnIsFocusPropertyChanged));
private static void OnIsFocusPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var uie = (UIElement)d;
if ((bool)e.NewValue)
{
(uie as PASDatePicker).Focus();
}
}
#endregion
}
}
I am using this datepicker in my code and trying to set focus using the Isfocus attached property defined above.
-- test form xaml
<Window x:Class="Guardian.PAS.BARSLibrary.Test.frmPASDatePickerTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="frmPASDatePickerTest" Height="300" Width="300"
xmlns:my="clr-namespace:Guardian.PAS.PASFramework.UI.WPF;assembly=Guardian.PAS.PASFramework.UI.WPF">
<Grid>
<my:PASDatePicker Name="dtpDate" Height="25" Margin="64,40,64,0" VerticalAlignment="Top"
my:PASDatePicker.IsFocus ="{Binding GoviddateissuedFocused}" />
<Button Height="23" Margin="64,90,139,0" Name="button1" VerticalAlignment="Top" Click="button1_Click">change</Button>
</Grid>
</Window>
-- Test form xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Reflection;
using Microsoft.Windows.Controls;
using System.Configuration;
using System.Data;
using System.Collections;
using System.ComponentModel;
namespace Guardian.PAS.BARSLibrary.Test
{
public partial class frmPASDatePickerTest : Window, INotifyPropertyChanged
{
public frmPASDatePickerTest()
{
InitializeComponent();
dtpDate.Focus();
}
private bool _goviddateissuedFocused = false;
public bool GoviddateissuedFocused
{
get { return _goviddateissuedFocused; }
set
{
if (_goviddateissuedFocused != value)
{
_goviddateissuedFocused = value;
RaisePropertyChanged("GoviddateissuedFocused");
}
}
}
#region PropertyChanged Block
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string property)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}
#endregion
private void button1_Click(object sender, RoutedEventArgs e)
{
GoviddateissuedFocused = true;
}
}
}
Now when i click on change button the datepicker does not get the focus.
Please help!
Thanks in advance!
Regards,
Samar
modified on Thursday, September 23, 2010 8:02 AM
|
|
|
|
|
Hi dashingsidds,
Change it into normal dp. We normally use AttachedProperty when we have child elements. In this case no need of AttachedProperty.
To-Resolve this issue: Ensure, the PropertyChanged is getting fired properly and/or PropertyChanged is not null.
HTH
|
|
|
|
|
Hello,
I have a custom control, and in the Xaml declaration I set its FontFamily and FontSize properties to Consolas and 72 respectively. However, in the constructor, the FontFamily is Segoe UI and FontSize is 12 - and I haven't done any kind of editing of those properties other than the Xaml.
Would could cause this?
Thanks,
Theo
EDIT: I just tested something - if I set the FontFamily to be Consolas in the constructor, it still renders the text as if it were Segoe UI, and in the child TextView control, in its constructors, the debugger displays the control's FontFamily to be Segoe UI.
|
|
|
|
|
Could you please share some more details like code snippet of your constructor, OnApplyTemplate and the XAML block you are setting the font properties?
|
|
|
|
|
Compared to others i am realy confused with this control.
I have 2 classes:
public class DataProcessItem : INotifyPropertyChanged, ICloneable, IEditableObject<br />
public class DataProcessList : ObservableCollection<DataProcessItem><br />
DataProcessItem has exposed properties:
public String LongFileName<br />
public String ShortFileName<br />
public String WindowText<br />
public uint Handle<br />
public Image FileIcon
so how do i bind DataProcessList to Datagrid and populate? This class will not be used with Dataset or binded from database. I will populate with a code.
and second question is how do i add columns and items programaticly without editing xaml.
Thank you in advance. Also a code here is not full, only a most important pieces
Edit: I am using .NET framework 4.0 so i do not need WPF toolkit
|
|
|
|
|
Saksida Bojan wrote: DataProcessList
You need to set the ItemSource of the Datagrid to DataProcessList.
To add columns programmatically, use DataGrid.Columns.Add(new DataGridTextColumn()); .
You can also have a look at this thread.
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.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Does not help me
<DataGrid x:Name="gridSelectProcess" Grid.Row="1" ItemsSource="{Binding Source=local:DataProcessList}" AutoGenerateColumns="True">
</DataGrid>
Only thing is that it shows are black empty lines
|
|
|
|
|
For datagrid you can try
WPF DataGrid Practical Examples[^]
Well, the example is using toolkit, but you can easily adjust the code to use your own DataGrid, as the process remains same.
You can also use
Grid using ListView[^] to create grid using Listview in WPF if you wish.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
I did attempt to read that article. For me it confusing, because it uses DataSet and it is binded to northwind databas, while i wan't to use a custom class in non database driven source. (Such as .Accsess, MySQL or MSSQL). Gonna save in xml with a specific format. This format would be a collection of sevral diffrent types of items.
also Grid using ListView seems promesing gonna check it out.
Edit: Got it working, however i needed to put ItemSource in code behind, not in xaml.
Final question about datagrid. How do i make DataGrid to show images?
thank you for your time
modified on Wednesday, September 22, 2010 4:28 PM
|
|
|
|
|
hello
once more a post about the expander animation.
i found a lot of xaml examples for a animated expander during expand/collapse.
like this => http://mattserbinski.com/blog/animating-expander
but how can i do that programmatically in codebehind?
i have a usercontrol which gets added a dynamic created nested expander control (min. 3 level).
i would like to have a "global" animation ( for expand /collapse) for all expander controls inside the usercontrol.
how can i solve that ?
with a RessourceDictionary ?
thanks for your help
|
|
|
|
|
Why do you need to do this in codebehind?
I dont think it is a good idea to do this in codebehind. Even though you can do that easily using
StoryBoard classes.
tronix01 wrote: would like to have a "global" animation ( for expand /collapse) for all expander controls inside the usercontrol.
Use Style and define the style in App.Xaml.
Refer to the style using {StaticResource key}
I think you could better read about WPF resources from my articles :
http://www.abhisheksur.com/2010/05/new-wpf-learning-series.html[^]
I hope these would help you.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
you are right. thanks for your reply.
|
|
|
|
|
Hi, this may seem like a stupid question, but I've looked everywhere and I couldn't find anything that could help me.
I'm developing a WPF project and in it I have two user controls, at the moment the first has only one button and the second is pretty much a canvas with a custom border.
Both of them have been added to the main window in their respective locations. What I want is, when I click the button in the first user control another control is added to the my second user control (canvas). Since I'm a bit desparate and confused about all this, I would just settle for a simple message box to show, with the code being written in the canvas code behind.
Everywhere I looked said that routed commands where the best option, but I cant seem to make them work. I should also say that I can make the routed commands work only inside the first user control.
Both user controls are in the same project, but have different namespaces.
I'd appreciate any help and I appologise if my question seems unclear.
Thanks
|
|
|
|
|
Well, generally WPF code is made data driven.
So from the Usercontrol use DataContext to pass a Dataobject on the User Control. Make the adjustment so that the user control loads something whenever the data object is modified. We use this by implementing the data class from INotifyPropertyChanged .
INotifyPropertyChanged[^]
Other than that you can also keep a property/dependency property to help load the object from outside.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Hello Experts,
Is it possible to check from Batch (.cmd or .bat) file, whether the Silverlight plugin has been installed. Also, I want the current installed version if it is already installed there.
Can anyone please help me to resolve it? Any kind of help is soliciated. Thanks in advance.
|
|
|
|
|
KunalChowdhury wrote: Is it possible to check from Batch (.cmd or .bat) file, whether the Silverlight plugin has been installed.
Why would you want to do this? Silverlight is meant to be installed from the web, and browsing to a page which requires an updated version will prompt the user to upgrade their version of Silverlight. If your application relies on the latest version, remember that the user will have browsed to it and it will run inside the security sandbox.
|
|
|
|
|
Pete O'Hanlon wrote: Why would you want to do this?
Actually Pete, I wanted to do some R&D on the Silverlight installation process for one of my new Article and hence I want to know whether I can do this from command prompt (i.e. from a batch file). I think, we can do this but not sure how.
Let me know, if you have any solution or any related links for the problem. Thanks for the response.
|
|
|
|
|
I would write a script to read the HKLM\SOFTWARE\Microsoft\Silverlight key in the registry.
For e.g. try this in a batch file to get the version.
ECHO OFF
REGEDIT /E %Temp%.\filename.REG "HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\"
FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%.\filename.REG ^| FIND "Version"') DO SET Version=%%B
SET Silverlight Version=%Version:"=%
SET Silverlight Version
DEL %Temp%.\filename.reg
PAUSE
This very simple script works for me.
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.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi Abhinav,
Thanks for your response. But as it depends on the Regedit, will not work on MAC or Linux. Though my requirement is only for Windows, so I will check whether it will resolve my problem.
BTW, Directly working with Regedit is not a good idea. User can hamper anything if I put it as plain text.
Again, thanks for the response. I got some basic pointers. If you have any other proper way to do this, please let me know.
|
|
|
|
|
KunalChowdhury wrote: work on MAC or Linux
Yeah true.
I was wondering - is there a way to somehow go through the plugin list for the browsers using a batch file?
Or you could modify the script to find a different way to check on MAC.....just throwing up some ideas.
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.
My latest tip/trick
Visit the Hindi forum here.
modified on Tuesday, September 21, 2010 4:54 AM
|
|
|
|
|
Hi Abhinav,
I got some idea on what I have to do. I will create a simple HTA application which will give me the silverlight version using javascript and then based on the installed version, I will be able to run the silverlight installer thru Javascript silently.
Will publish an article soon.
|
|
|
|
|
I'm not sure it will be able to install silently. At the very least, I'd expect you to get a File Download - Security Warning as the installer is an .exe on Windows.
|
|
|
|
|
Pete O'Hanlon wrote: I'm not sure it will be able to install silently. At the very least, I'd expect you to get a File Download - Security Warning as the installer is an .exe on Windows.
I am planning to package the runtime as an installable for my application (for the article). In this case, it will be able to install silently.
|
|
|
|