Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

Memory Leak with TreeView

$
0
0

I'm currently experiencing a memory leak in WPF where I am using A TreeView which is databinding to a list.  Each item in the list will display a custom control.  When an item is removed from the list and the custom control is no longer displayed the control is not disposed of.  The control has bindings to dependecyproperties. 

I've read several posts where they suggested to clear all the bindings.  Where does that occur, in the view model or the control code?  I'm not able to get a method to dispose / shutdown for the control.

Is there a known memory leak in the TreeView for WPF?




Quick options control in WPF for controls...

$
0
0

Hi all,

In Microsoft Word you get a quick formating box when you select the text in the document which is half visible.

I want to do same operation in a WPF application, when user select some text in textbox he should be able to see some options on a custom control which will be half visible initially and when user moves on it it will be completly visible.

Is it possible in WPF by default? If not how i can do this in WPF? Any link or document related to this will help me.

Thanks in advance,

IamHuM

Root Cause: Recursive call to Automation Peer API is not valid

$
0
0

Hi,

We've used WPF Tookit DataGrid and .NET 3.5 for about 2 years. And we've got two cases which throw exception - "Recursive call to Automation Peer API is not valid".It's quit strange and eratic, very few PCs has such issue.

Case One:

A dropdown combox (WPF Tookit DataGrid as DropDown content control):

And it can be resolved by:

protectedoverrideAutomationPeerOnCreateAutomationPeer()
{
  
returnnull;
}

This solution is from http://stackoverflow.com/questions/4017786/wpf-recursive-call-to-automation-peer-api-is-not-valid.

Case Two:

A WPF Tookit DataGrid has a Temlate Column , which the cell template has a dropdown combox (WPF Tookit DataGrid as DropDown content control). It can not be fixed by the solution above.

Exception Stack:

Exception object: 0ac4e048
Exception type:   System.InvalidOperationException
Message:          Recursive call to Automation Peer API is not valid.
InnerException:   <none>
StackTrace (generated):
    SP       IP       Function
    0036E3A4 61A0CEFE PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.GetChildren()+0x366bde
    0036E3D4 616A5C34 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x18
    0036E3EC 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E404 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E41C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E434 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E44C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E464 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E47C 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E494 616A5E52 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(System.Windows.Automation.Peers.AutomationPeer)+0xaa
    0036E4A8 616A444E PresentationCore_ni!MS.Internal.Automation.ElementProxy.StaticWrap(System.Windows.Automation.Peers.AutomationPeer, System.Windows.Automation.Peers.AutomationPeer)+0x1a
    0036E4C0 616A7C69 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.UpdateChildrenInternal(Int32)+0x341
    0036E52C 616A791A PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()+0xa
    0036E530 11EDC66E UNKNOWN!Microsoft.Windows.Automation.Peers.DataGridItemAutomationPeer.GetChildrenCore()+0x1e
    0036E540 616A662B PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()+0x23
    0036E558 616A634C PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.GetChildren()+0x2c
    0036E588 616A5C34 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x18
    0036E5A0 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E5B8 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E5D0 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E5E8 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E600 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E618 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E630 616A5C73 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(System.Windows.Automation.Peers.AutomationPeer)+0x57
    0036E648 616A5E52 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(System.Windows.Automation.Peers.AutomationPeer)+0xaa
    0036E65C 616A444E PresentationCore_ni!MS.Internal.Automation.ElementProxy.StaticWrap(System.Windows.Automation.Peers.AutomationPeer, System.Windows.Automation.Peers.AutomationPeer)+0x1a
    0036E674 616A6F3E PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.ProviderFromPeer(System.Windows.Automation.Peers.AutomationPeer)+0x1e
    0036E680 619DBBD1 PresentationCore_ni!System.Windows.Automation.Peers.AutomationPeer.RaiseAutomationEvent(System.Windows.Automation.Peers.AutomationEvents)+0x7ab6d5
    0036E690 609783AA PresentationFramework_ni!System.Windows.Automation.Peers.SelectorAutomationPeer.RaiseSelectionEvents(System.Windows.Controls.SelectionChangedEventArgs)+0x22
    0036E6B0 60C48560 PresentationFramework_ni!System.Windows.Controls.ComboBox.OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs)+0xbef278
    0036E6C4 124C17E7 UNKNOWN!UNKNOWN+0x17
    0036E6EC 60061113 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector.InvokeSelectionChanged(System.Collections.Generic.List`1<System.Object>, System.Collections.Generic.List`1<System.Object>)+0x4f
    0036E704 6005FE17 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector+SelectionChanger.End()+0xdf
    0036E738 6005E325 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector+SelectionChanger.SelectJustThisItem(System.Object, Boolean)+0x11d
    0036E76C 60060D02 PresentationFramework_ni!System.Windows.Controls.Primitives.Selector.OnSelectedItemChanged(System.Windows.DependencyObject, System.Windows.DependencyPropertyChangedEventArgs)+0xb2
    0036E798 627585EC WindowsBase_ni!Unknown+0x4c
    0036E7C4 60073E40 PresentationFramework_ni!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs)+0x50
    0036E8F4 627583BC WindowsBase_ni!Unknown+0x3c
    0036E94C 6275676B WindowsBase_ni!Unknown+0x71b
    0036EA0C 627594CD WindowsBase_ni!Unknown+0xad
    0036EA34 600AD85A PresentationFramework_ni!System.Windows.Data.BindingExpressionBase.Invalidate(Boolean)+0x62
    0036EA4C 600AD31D PresentationFramework_ni!System.Windows.Data.BindingExpression.TransferValue(System.Object, Boolean)+0x1fd
    0036EAA0 600AA9D8 PresentationFramework_ni!System.Windows.Data.BindingExpression.Activate(System.Object)+0x194
    0036EACC 60097C49 PresentationFramework_ni!System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt)+0x38d
    0036EB74 600C3D51 PresentationFramework_ni!System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean)+0x19
    0036EB80 600C3D19 PresentationFramework_ni!MS.Internal.Data.DataBindEngine+Task.Run(Boolean)+0x31
    0036EB94 600C3C36 PresentationFramework_ni!MS.Internal.Data.DataBindEngine.Run(System.Object)+0xb6
    0036EBB0 600C2CBA PresentationFramework_ni!MS.Internal.Data.DataBindEngine.OnLayoutUpdated(System.Object, System.EventArgs)+0x1e
    0036EBC0 61271CD8 PresentationCore_ni!System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()+0x154
    0036EBF8 6127159E PresentationCore_ni!System.Windows.ContextLayoutManager.UpdateLayout()+0x926
    0036ECF8 61277F4D PresentationCore_ni!System.Windows.ContextLayoutManager.UpdateLayoutCallback(System.Object)+0x19
    0036ECFC 61277F28 PresentationCore_ni!System.Windows.Media.MediaContext+InvokeOnRenderCallback.DoWork()+0x10
    0036ED00 61277EC2 PresentationCore_ni!System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()+0x76
    0036ED1C 6127785A PresentationCore_ni!System.Windows.Media.MediaContext.RenderMessageHandlerCore(System.Object)+0x8a
    0036ED68 612777AA PresentationCore_ni!System.Windows.Media.MediaContext.RenderMessageHandler(System.Object)+0x6e
    0036ED80 6274FE83 WindowsBase_ni!Unknown+0x53
    0036EDA0 6274FE0C WindowsBase_ni!Unknown+0x9c
    0036EDE8 62752C95 WindowsBase_ni!Unknown+0x8d
    0036EE24 62752BF8 WindowsBase_ni!Unknown+0x38
    0036EE2C 642F4D85 mscorlib_ni!System.Threading.ExecutionContext.runTryCode(System.Object)+0x51
    0036F2D0 642F4C8A mscorlib_ni!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x6a
    0036F2E8 642F7F92 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)+0x7e
    0036F30C 642F7F04 mscorlib_ni!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)+0x2c
    0036F328 62752B28 WindowsBase_ni!Unknown+0x68
    0036F364 6274E7FE WindowsBase_ni!Unknown+0x15e
    0036F3A8 6274E9D7 WindowsBase_ni!Unknown+0x63
    0036F3F8 627500A6 WindowsBase_ni!Unknown+0xbe
    0036F444 6274FFD5 WindowsBase_ni!Unknown+0x7d
    0036F454 6274FE83 WindowsBase_ni!Unknown+0x53
    0036F474 6274FDB2 WindowsBase_ni!Unknown+0x42
    0036F4BC 6274E2CC WindowsBase_ni!Unknown+0xb4
    0036F504 6274F8B8 WindowsBase_ni!Unknown+0x104

Many threads just has a walkaround solution about the issue, Does any one know have any idea about theRoot Cause of Recursive call to Automation Peer API is not valid?


袁勇

ListBox is not populated with an XMl binding with a file

$
0
0

Hi All,

I have just started WPF on .Net3.5.

I am facing a concern while populating ListBox from an xml file. Actually this xml file has been generated with someobject.WriteXml operation on a local data object. It looks like this:

<?xml version="1.0" standalone="yes"?><NewDataSet><xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="AnniversaryDetails"><xs:complexType><xs:sequence><xs:element name="Event_Id" msdata:AutoIncrement="true" msdata:AutoIncrementSeed="1" type="xs:int" minOccurs="0" /><xs:element name="Event_Name" type="xs:string" minOccurs="0" /><xs:element name="Event_Type" type="xs:string" minOccurs="0" /><xs:element name="Event_DateTime" type="xs:dateTime" minOccurs="0" /><xs:element name="Event_PicUrl" type="xs:string" minOccurs="0" /><xs:element name="Event_IsAlarmReq" type="xs:boolean" minOccurs="0" /></xs:sequence></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema><AnniversaryDetails><Event_Id>1</Event_Id><Event_Name>Test Event</Event_Name><Event_Type>Others</Event_Type><Event_DateTime>2013-03-31T12:22:06.5200419+05:30</Event_DateTime><Event_PicUrl /><Event_IsAlarmReq>false</Event_IsAlarmReq></AnniversaryDetails></NewDataSet>

My Xaml file looks like:

 
<Window.Resources><XmlDataProvider x:Key="rk" IsAsynchronous="False" IsInitialLoadEnabled="True"/></Window.Resources>    <ListBox Name="listViewRecords" Grid.Column="0" DataContext="{Binding {StaticResource rk}, XPath=NewDataSet/AnniversaryDetails}"  />

The XAML.cs file has following COnstructor:

        public MyManager()
        {
            InitializeComponent();
            XmlDocument d = new XmlDocument();
            d.Load(@"d:\rohit\test\data.xml");          
            ((XmlDataProvider)Resources["rk"]).Document = d;
        }

I want the Event_Name should be displayed in the listbox.  Please help..

Thanks

Regards

Rohit

CRUD operations in a wpf datagrid using Castle active records

$
0
0
Hi everyone.

So I am working on an application that uses Castle Active Records. I use Visual Studio 2012, C# and wpf. My assignment is to take a table from a database (oracle) and using the wpf datagrid enable the user to do crud operations on it. Now I did this before using a form and the model view presenter pattern but I have no idea how to do this the Active records way. I have installed what is needed and am able to show the data on the datagrid from the table but that is the limit of my capabilities of the moment so I am hoping you guys can help.

Here is my window:

<DockPanel Margin="5"><Border DockPanel.Dock="Top"
            Style="{StaticResource header}"><StackPanel Orientation="Horizontal"><TextBlock Text="Prodajna Mjesta ( " /><TextBlock Text="{Binding ProdajnaMjesta.Count}"/><TextBlock Text=")"/></StackPanel></Border><StackPanel DockPanel.Dock="Bottom"><Button Content="Spasi" Width="75" HorizontalAlignment="Right" Click="Spasi_Click"

                /></StackPanel><DataGrid 
        Name="dg"
        Margin="5"


        ItemsSource="{Binding Path=ProdajnaMjesta}"
                 AutoGenerateColumns="False"

              IsReadOnly="False"



            FontFamily="Trebuchet"
        Foreground="Black"><!--Button.Click="OpenOprema_Click"--><!--IsSynchronizedWithCurrentItem="True"--><DataGrid.Columns><DataGridTextColumn   Header="ID" Binding="{Binding Id}" /><DataGridTextColumn   Header="PTT" Binding="{Binding Ptt}" /><DataGridTextColumn   Header="Adresa" Binding="{Binding Adresa}" /><DataGridTextColumn   Header="Aktivan" Binding="{Binding Aktivan}" /><DataGridTextColumn   Header="Region" Binding="{Binding Region}" /><DataGridTextColumn   Header="Opcina" Binding="{Binding Opstina}" /><DataGridTextColumn   Header="Datum" Binding="{Binding Datum, StringFormat= d}" /><DataGridTextColumn   Header="Telefon" Binding="{Binding Telefon}" /></DataGrid.Columns></DataGrid></DockPanel>




And the window has a presenter:

public class ProdajnaMjestaPresenter : PresenterBase<ProdajnaMjestaWindow>

{
    //private ApplicationPresenter _applicationPresenter;

    private GlavniRepository _glavniRepository;
    private ObservableCollection<ProdajnoMjesto> _prodajnaMjesta;




    public ProdajnaMjestaPresenter(GlavniRepository glavniRepository, ProdajnaMjestaWindow window)
        : base(window)
    {
        //_applicationPresenter = applicationPresenter;
        //_entitetiWindow = _applicationPresenter.EntitetiWindow;
        _glavniRepository = glavniRepository;
        _prodajnaMjesta = _glavniRepository.ProdajnaMjesta;

        //applicationPresenter.View.busyIndicator.IsBusy = false;
    }

    public void Zatvori()
    {
        //_applicationPresenter.View.glavniContent.Content = null;
        //_applicationPresenter.PrikaziLoginformu();
    }

    public ObservableCollection<ProdajnoMjesto> ProdajnaMjesta
    {
        get { return _prodajnaMjesta; }
        set
        { _prodajnaMjesta = value; }
    }

        public void SpasiProdajnoMjesto()
    {
        _glavniRepository.SpasiProdajnoMjesto();
    }

}

}



As you can see there is also the main repository where the method SpasiProdajnoMjesto (Save) tries to go but just leads to an empty method. Anyway I hope you guys can help and thanks once again.

   

Create border/Square with hollow center.

$
0
0

Hi,

I want to create a control in WPF/Silverlight. This control is rectangle/border which is hollow from the center. My intention is to grayed out everything else except for a squared area within the rectangle/border container.

Also, I want that hollow part to be able to move based on mouse movement. I've created a sample application.  I have used the following code to achieve this: 

<Grid><Image x:Name="_image" Source="pack://siteoforigin:,,,/sample_10.jpg" Stretch="Fill" /><Path x:Name="mask" Fill="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" Opacity="0.895" MouseMove="Path_MouseMove_1" ><Path.Data><CombinedGeometry GeometryCombineMode="Exclude"><CombinedGeometry.Geometry1><RectangleGeometry RadiusX="5" RadiusY="5" Rect="0,0,517,319" /></CombinedGeometry.Geometry1><CombinedGeometry.Geometry2><RectangleGeometry RadiusX="5" RadiusY="5" Rect="{Binding RectProperty}" /></CombinedGeometry.Geometry2></CombinedGeometry></Path.Data></Path></Grid>

Outpur for above will look like this: 

Now the problem is that when I try to move mouse some time application hangs. I hope it may because for each mouse movement I am inserting a new "Rect" to change it's location. 

Is there any alternate solution to achieve this or to make movement smooth. 

Thanks everyone for help in advance. 


Blog, , Twitter - My Apps - Mark post as answer if you find this post as a solution, to help others.

Implement algoritm as in Excel Color scale.

$
0
0

Hi

I want to try functionality in DataGrid as in Excel with color scale.

I have 2d array and I need to set color for each cell according to cell value.

Color scale Green - Yellow - Red

Can someone to tell about algoritm convert value in Grid to RGD for cell?

How Can I show collection of collection bind to DataGrid?

$
0
0

Hello

I want to group some objects in Data Grid. It works fine. But I want to class properties works as group headers and for rows I want use their List<AntoherClass> variable.

Is that possible?

If doesn’t have to be List<> collection. It can be another collection.

Best Regards

Przemysław Staniszewski


strikethrough in gridview

$
0
0

Hey,

I word on windows RT. 

I have a ListView, each element have a picture and a text. I bind like this : ItemTemplate="{StaticResource ListItemTemplate}

I would lik to strikethrough the text of the elements of my choise.

Could not find any property to do that on winRT.

Thanks for your time,

Alexandre

DataGrid using MVVM with CanUserAddRows with validation enabled?

$
0
0

Hello,

I've been struggling for days to implement a DataGrid using the MVVM pattern that sets DataGrid.CanUserAddRows=true and uses Binding.ValidationRules for validation.  Unfortunately this has lead down multiple rabbit-holes that dead-end.

Just one example: Why do validation rules not fire when a the user clicks on a new row and then clicks away?  No data changes, so there is no way to stop a blank row from being added to the collection backing the datagrid.  I've taken multiple tries at hacking correct behavior into the control at the code-behind level and using attached behaviors, but no approach seems to work 100% correctly and I get the feeling I'm missing something simple and/or important or there are bugs in the implementation of the control in WPF.

And plese spare me the basics on binding - the problem isn't there.  My collection class derives from and properly implements  ObservableCollection<T>, IEditableObject and my row class derives from and properly implements INotifyPropertyChangedIEditableObjectIEditableObjectProperty  Believe me, I have wasted a lot of time on this.

Rather than go into the multiple issues involved could someone at Microsoft please provide a complete, reasonably clean code sample project that demonstrates how to implement a DataGrid that implements in-place (preferrably one-click) data editing, in-place row adding (aka CauUerAddRows), and a per-row delete button, using MVVM Binding and that correctly calls into the ViewModel for validation?

Thanks in advance.

Some references that might be helpful:

http://stackoverflow.com/questions/4106056/wpf-datagrid-handling-canuseraddrows-true-cleanly-with-mvvm

http://stackoverflow.com/questions/2060046/wpf-datagrid-allow-user-to-add-rows

http://blogs.msdn.com/b/vinsibal/archive/2008/05/20/wpf-3-5-sp1-feature-ieditablecollectionview.aspx

http://stackoverflow.com/questions/9786612/how-to-get-datagrideditaction-cancel

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/1665e197-f7df-476f-a139-061f871b0434/

http://www.codeproject.com/Articles/30905/WPF-DataGrid-Practical-Examples#validation

http://wpf.codeplex.com/discussions/34847

http://stackoverflow.com/questions/4833100/updatesourcetrigger-propertychanged-equivalent-for-a-windows-phone-7-textbox

http://blogs.msdn.com/b/vinsibal/archive/2008/11/05/wpf-datagrid-new-item-template-sample.aspx

http://www.a2zdotnet.com/View.aspx?Id=135#.UVOhIVeH98E

http://wpf.codeplex.com/discussions/60355?ProjectName=wpf

http://stackoverflow.com/questions/10388466/wpf-datagrid-celleditended-event

http://stackoverflow.com/questions/8877391/wpf-datagrid-celleditending-c-sharp

http://www.codeproject.com/Articles/15239/Validation-in-Windows-Presentation-Foundation

http://stackoverflow.com/questions/6598241/wpf-datagrid-new-row-validation

In WPF/MVVM, how to implement the “Select All” function in a perfect way

$
0
0

In View, i.e. the XAML, I have binded the SelectAll bool value to the Checkbox control

<CheckBoxGrid.Row="5"Content="Select All"HorizontalAlignment="Left"Margin="0,5, 0, 0"IsChecked="{Binding Path=SelectAll, Mode=TwoWay}"Width="206"></CheckBox>

and fullfill the SelectAll as

publicboolSelectAll{get{returnthis.Get<bool>("SelectAll");}set{this.Set<bool>("SelectAll", value);if(this.SelectAllCommand.CanExecute(null))this.SelectAllCommand.Execute(value);}}

Yes, it looks good, but I have an issue...

When all the checkboxes are selected manually, the selectall checkbox should be selected automatically... at that time, we don't want the SelectAllCommand command to be executed...

How can I do it..... I know maybe it is an easy job, but how to do it perfectly....

Thanks for giving me some advices in advance

TextBox Problem with numeric input

$
0
0

Hi!

I have in a WPF Maske 4 TextBoxes...

1. A Number in a length from 9.
--> OK, I can find out is there a number or not and how many character are in the TextBox
     This is finish...

2. A Number with the folowing Input/Output:
    "10.200.333,95-" (Only Numbers and ".,-" allowed...)
                                But only 1 time ".,-"  and i Need an automatic "." for the number
                                eg.: "10000,00" = "10.000,00"

3. A Special Numberfield:
   "10/100/3303"  this is a partnumber from a car....
                          Only Numbers and "/"  are allowed and I Need here to an automatic for this:
                          eg.: "101003303" = "10/100/3303"

4. A TextBox with Auto Number like this:
    "     99,00"  the Field is normal "9999999,99"  so what I mean is an automatic Zero = Space
                      mechanism

Best regards

Bernd    

 

ScrollViewer.ScrollToHorizontalOffset / .ScrollToVerticalOffset stop working if called "too often"

$
0
0

Hi

I'm using the ScrollViewer to create a view port on a rather large canvas with many objects on it (it's part of a drawing application). I found that when using the ScrollViewer's scroll bars the performance on moving the view port horizontally / vertically is excellent and it works as expected.

However, I also want the user to be able to pan with the mouse, by clicking the canvas and drag the mouse. This functionality is implemented by capturing the MouseLeftButtonDown to start the panning and the MouseMove to actually move the view port. The view port offset then is moved by calling .ScrollToHorizontalOffset and .ScrollToVerticalOffset on the ScrollViewer.

This generally works fine. However, I found that when either the user moves the mouse really rapidly or if the rendering of the view port contents takes "longer than normally" (i.e. due to the amount of objects) at some point the .ScrollToHorizontalOffset and .ScrollToVerticalOffset calls simply stop doing anything.

When this happens, also the ScrollChanged event no longer occurs (at least it's consistent).

It seems that there is some code somewhere in WPF, that stops accepting "ScrollTo" calls if the calls happen too frequently.

Is this know / expected behavior? Is there anything I can do to get around this behavior?

Thanks for any ideas
Oskar.

Visual Studio 2012 WPF Designer & Satellite Assemblies

$
0
0

Dear all,

I'm developing a localization extension for WPF and other Frameworks based on MarkupExtension with design-time support. This worked well for VS 2010.

Beginning with VS2012 (and earlier with Blend) I experienced a strange behaviour of the WPF designer: It only loads one additional satellite assembly (apparently the first one of all available ones sorted by their names). The others are not included. As this still works well in run-time (all satellite assemblies are well created and fully functional), I've debugged into this: The designer process creates a shadow cache of the programm and includes only one additional satellite assembly, under:

\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache

So the question is: Is this behaviour "by design" and if yes, how can I tell the designer process to copy all satellite assemblies to the shadow cache.

Thank you in advance.

Best regards,

Uwe Mayer



How to listen to a BindingBase object?

$
0
0

Hi

I want to create a special DataTrigger inheriting the TriggerBase<FrameworkElement>. Just similar to theDataTrigger, a property of type BindingBase has been defined in theMyDataTrigger class. 

How can I listen to it in order to trace its changes?

    public class MyDataTrigger : TriggerBase<FrameworkElement>
    {
        ...

        /// <summary>
        /// [Wrapper property for BindingProperty]
        /// <para>
        /// Gets or sets the binding that produces the
        /// property value of the data object.
        /// </para>
        /// </summary>
        public BindingBase Binding
        {
            get { return (BindingBase)GetValue(BindingProperty); }
            set { SetValue(BindingProperty, value); }
        }

        public static readonly DependencyProperty BindingProperty =
            DependencyProperty.Register("Binding",
                                        typeof(BindingBase),
                                        typeof(MyDataTrigger),
                                        new FrameworkPropertyMetadata(null));

    }


More Info:

The main problem is that I don't know how to find the BindingBase associatedDependencyProperty. I know how to listen to a DP;

void ListenToDP(object component, DependencyProperty dp)
{
    DependencyPropertyDescriptor dpDescriptor = DependencyPropertyDescriptor.FromProperty(dp, component.GetType());
    dpDescriptor.AddValueChanged(component, DPListener_ValueChanged);
}

Where DPListener_ValueChanged is an EventHandler delegate. Here, thecomponent parameter value is this.AssociatedObject.


ListBox filter performance

$
0
0

Hi,

I am populating a (surface) listbox with about 1200 items of the following DataTemplate:

<DataTemplate x:Key="FileListDataTemplate"><StackPanel Orientation="Horizontal"><MediaElement x:Name="FileThumb" Source="{Binding Path=ShowSelectedMedia}" MinHeight="75" MaxWidth="192" MaxHeight="90"></MediaElement><Label MaxWidth="200" Content="{Binding Path=Filename}" /></StackPanel></DataTemplate>

It is a list of filenames in a folder on a websever and when the users selects one it displays the photo in the listitem that has its filename in the label of the listitem.

There is also a textbox on top of the the listbox which should filter the contents of the listbox and that where the problem arises.

Getting the ICollectionView of the listbox and applying the filter the following way:

filterText = SearchFileTextbox.Text;
ICollectionView cv = CollectionViewSource.GetDefaultView(Filenames);
cv.Filter = o =>
  {
    FTPFileListModel f = o as FTPFileListModel;
    return f.Filename.Contains(filterText);
  };

It results in a UI that hangs for 4-5 seconds when entering the first letters in the textbox. How could I avoid this? A BackgroundWorker? Could someone provide an example?

I have tried to put all this in a BGWorker:

ICollectionView cv = CollectionViewSource.GetDefaultView(Filenames);
cv.Filter = o =>
{
   FTPFileListModel f = o as FTPFileListModel;
   return f.Filename.Contains(filterText);
};

But this doen't update the view, as if I was not writting anything in the textbox although the code gets executed because the breakpoint is hit.

Thanks for any help

Greg

datagrid, manual render column not work

$
0
0

hi,

I have in MainWindow()  this code:

dgUsers.DataContext = persons;
persons is a list<person>. Person is data container with atribute name,surname,...

In xaml have this code and works super:

<DataGrid Name="dgUsers" ItemsSource="{Binding}"  CanUserAddRows="True"> </DataGrid>

But i need manual render columnt and this code dont work:

<DataGrid Name="dgUsers" ItemsSource="{Binding}"  CanUserAddRows="True" AutoGenerateColumns="False"><DataGridTextColumn Header="Name" Binding="{Binding Path=Name}"></DataGridTextColumn></DataGrid>

Where is mistake? Thanks


WPF event handling?

$
0
0

Does anyone have an idea where to find some kind of overview about how the events in WPF work. I'm not asking "how to", but rather "what the...". ;-)

I don't even know if the events are WPF-events, .NET-events, C#-events or CLR-events (= where to look).

If there were some picture of related entities (classes, objects, methods, members,...) and their connections and roles to each other, that would be outstanding.

Re-size DrawingVisual after rotation.

$
0
0

I am facing issue in calculating the center of the DrawingVisual when it is already rotated, and resized.

I am doing one tool which allows drawing of various shapes in the canvas.

I created a Shape class which derives from  DrawingVisual and rectange class from the shape.

GraphicsRectangle--> GraphicsShape --> GraphicsBase-> DrawingVisual 

Did the rotation related code in the GraphicsShape.

And GraphicsBase is the abstract like class with has some basic function with required for my appln. GraphicsRectangle has code related to resize of rectangle.

I am using GroupTransform for translation and rotation, and set the GroupTransform  object to the DrawingVisual.Transform

I am facing problem in finding the center of the DrawingVisual during the following step.

1. rotate the object to some angle. (say 45)

2. Resize the object.

3. Again rotate. <problem in recalculation of center for rotation tansform>

Every time when i rotate i calculate the center for rotation. Calculation on the center gives a wrong value only when i re-sized object and object shifts to some other place and start rotating.

                                                                                                  

public abstract class GraphicsShape : GraphicsBase { protected virtual Point GetCenter() { Rect rect = this.GetBounds(); var r = this.TransformGroup.TransformBounds(rect); Point p1 = new Point(r.Left, r.Top); Point p2 = new Point(r.Right, r.Bottom); Point c = new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2); return c; } public virtual void StartMove(Point startPoint, int handleNumber) { this.centerPoint = GetCenter(); this.startVector = Point.Subtract(startPoint, this.centerPoint); this.initialAngle = this.rotateTransform.Angle % 360; Rect r = this.GetBounds(); Point p1 = new Point(Math.Min(r.Left, r.Right), Math.Min(r.Top, r.Bottom)); Point p2 = new Point(Math.Max(r.Left, r.Right), Math.Max(r.Top, r.Bottom)); Point c = new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2); if (SizeChanged) { SizeChanged = false; } this.rotateTransform.CenterX = c.X; this.rotateTransform.CenterY = c.Y; Console.WriteLine("Start()-Angle: " + this.rotateTransform.Angle); }

 private void Delta(Point currentPoint)
        {

            Vector deltaVector = Point.Subtract(currentPoint, this.centerPoint);

            double angle = Vector.AngleBetween(this.startVector, deltaVector);



            this.rotateTransform.Angle = (this.initialAngle + Math.Round(angle, 0));//;% 360.0;

            Console.WriteLine("Delta()-Angle: " + angle + string.Format("     Center: {0} SV: {1} EV: {2}", centerPoint, startVector, deltaVector));

            
        }

  protected override void DoMoveHandleTo(System.Windows.Point point, int handleNumber)
        {
            if (canRotate && RotateHandle == handleNumber)
            {
                    Delta(point);
            }
        }

}

StartMove will be called when i start rotating, Delta will be called for every rotate after start move.

In  start move i am calculating center every time when i start rotating. 

     
class GraphicsRectangle
{

                  
protected override void DoMoveHandleTo(Point point, int handleNumber)
        {
            var inverseP = this.TransformGroup.Inverse.Transform(point);
            switch (handleNumber)
            {
                case 1:
                    rectangleLeft = inverseP.X;
                    rectangleTop = inverseP.Y;
                    break;
                case 2:
                    rectangleTop = inverseP.Y;
                    break;
                case 3:
                    rectangleRight = inverseP.X;
                    rectangleTop = inverseP.Y;
                    break;
                case 4:
                    rectangleRight = inverseP.X;
                    break;
                case 5:
                    rectangleRight = inverseP.X;
                    rectangleBottom = inverseP.Y;
                    break;
                case 6:
                    rectangleBottom = inverseP.Y;
                    break;
                case 7:
                    rectangleLeft = inverseP.X;
                    rectangleBottom = inverseP.Y;
                    break;
                case 8:
                  //  this.rotateTransform.CenterX += this.rotateTransform.CenterY - (rectangleLeft - inverseP.X) / 2;
                    rectangleLeft = inverseP.X;

                    break;
                case int.MaxValue:
                    base.DoMoveHandleTo(point, handleNumber);
                    break;
            }
            if (handleNumber > 0 && handleNumber <= 8 && (this.rotateTransform.Angle%360)!=0)
            {
                SizeChanged = true;
            }
            RefreshDrawing();
        }

}
This is my rectange resize code

Please anyone provide me solution. when i combine Resize after Roation only problem coming. Translation of the object working fine.

Need code of dll wpfgfx_v0300.dll

$
0
0
Where can I find the code of wpfgfx_v0300.dll
Viewing all 18858 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>