|
Hi,
I would like to easily record the changes made to the of RichTextBox (user and/or programmatic) as well as the changes made to the FlowDocument and be able to save and play them again.
I was thinking about the do/undo queue of the document. How do I get access to it?
Also, can UIAutomation or something like this can help me?
In short, can you to me what my options are?
10x
Dani
|
|
|
|
|
I have a custom canvas control which sits inside a scrollviewer - I have implemented drag, drop and move for items on the canvas and overridden MeasureOverride so that when I move an item around on the canvas its size reflects the changes so if I move the item beyond the visible portion of the canvas it will resize to accomodate the moved item and scrollbars will show appropriately.
However if I then bring the item into view by using the scrollbars then start to move the item back out again the scrollbars go a bit haywire.
It's a rather poor explanation of the problem I afraid but I am not sure how else to put it but hopefully it will contain enough info for somebody to point me in the right direction.
|
|
|
|
|
Hi RugbyLeague,
I could understand the problem. You are having a visual studio designer like custom canvas control, in which you will be having controls. The problem is with scrollbar of the scroll viewer in which the canvas is hosted. Right?
RugbyLeague wrote: bit haywire.
Do you mean, the scroll bars of the scroll viewer not scrolling smoothly?
If that is the case. So far known best way is, You have to create your own calculation for updating the scrollviewer's vertical and horizontal offset.
|
|
|
|
|
If I move an object down to the right hand corner of the canvas then further so I can't see the object the scrollbars react accordingly. If I then bring the object into view by using the scrollbars then move the object again its as though the scrollbars think the object is back in the original viewable area of the canvas and disappear. if I then move the object to the bottom right again the scrollbars reappear but are out of synch with where they think the object is.
Similar behaviour is seen in the app in this article:
WPF Diagram Designer - Part 2[^]
|
|
|
|
|
I have managed to do a full row selection, however i can still see a black rectangle on a cell that i click on. How can i make it so that it will not show it?
Thanks in advance.
|
|
|
|
|
This[^] thread most probably answers your question.
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.
|
|
|
|
|
I am unable to achive this. One example uses DataGridFrozenGrid that is only avaible in Silverlight
others when selected, content disappears.
Edit: Partualy figure it out. All those wanted me to use VisualManager while i didn't know what it is. Also i wanted to see the default style and template to modify but was out of luck because template browser didn't saw DataGridCell.
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderThickness" Value="0"/>
</Trigger>
</Style.Triggers>
<Setter Property="Focusable" Value="False"/>
</Style>
</DataGrid.CellStyle>
The only thing that remaind is that i override key events, so that it handles up and down keys.
modified on Sunday, September 26, 2010 4:15 PM
|
|
|
|
|
Hi everyone,
it's my first post so be gentle . I'm having difficulties converting a colored image to grayscale in a silverlight application. Clicking the link you can see the results of my code (left is the original pic right the resulting grayscale pic):
Link
I have no idea what I'm doing wrong. It should work but it doesn't. Help would be appreciated!
One other thing, the WriteableBitmap.setPixel and WriteableBitmap.getPixel functions are part of the WritableBitmapEx library downloaded from Codeplex.
Here's the code:
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
convertToGrayscale(new WriteableBitmap((BitmapSource)this.Original.Source));
}
public void convertToGrayscale(WriteableBitmap image)
{
var p = image.Pixels;
for(int y=0; y<image.PixelHeight; y++)
{
for(int x=0; x < image.PixelWidth; x++)
{
Color c = image.GetPixel(x, y);
byte gray = (byte)((c.R*11 + c.G*16 + c.B*5)/32);
image.SetPixel(x, y, Color.FromArgb(c.A, gray, gray, gray));
}
}
this.resultImgBox.Source = image;
}
modified on Sunday, September 26, 2010 8:09 AM
|
|
|
|
|
Well - could be something wrong with the algorithm.
Try byte gray = (byte)((c.R + c.G + c.B)/3); instead.
See here.
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.
|
|
|
|
|
Already tried few different formulas (the one you proposed also) for calculating a gray pixel always with the same (bad looking) results.
|
|
|
|
|
Hi Lenquist
Ran some tests (i.e. setting the pixel to the returned GetPixel with no modification) and the image changed.
Turns out there is a problem with the GetPixel in the extensions library, which has been fixed.
You need to go to http://writeablebitmapex.codeplex.com/SourceControl/list/changesets and download the latest source and compile it yourself.
|
|
|
|
|
It works now, thanks for your answer!
|
|
|
|
|
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
|
|
|
|