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

Add DropBox file Sycn in WPF application

$
0
0

Dear all,

I need to implement in my application the synchronisation of Dropbox for files, what is the best wau to implement this synchonisation ?

I have seen that you can download Dropbox App and then it handle sycn automatically or need to implement authentication and api sycn process.

Does anyone of you have already implement this ? if yes is there any starting working sample in c# around to test the sycn process ?

thanks for help and advise

regards


C# XML comments for auto-generated WPF class members

$
0
0
The WPF engine automatically generates a number of public members for each class based on a XAML file: some infrastructure methods (IComponentConnector.Connect, InitializeComponent, possibly more) as well as fields or properties for any WPF elements that were named in the XAML file.

Unfortunately, the WPF engine does not generate (useful) XML comments for any of these members, which leads to blank spaces and angry red errors when Sandcastle builds a documentation file from such code.  I can't comment the code manually, either, because these members are all found in the auto-generated *.g.cs file that's overwritten with each compilation.

Providing sensible documentation for Connect & InitializeComponent is a job for the WPF team, but obviously the documentation for named XAML elements must be written by the developer who wrote the class.  The question is, how to provide such documentation?  Is there currently a trick to do this?

If not I think there should be such a mechanism, for example by evaluating a comment block that is nested within the named XAML element.

While sorting ListCollectionView it throws exception System.ArgumentOutOfRangeException : Index was out of range

$
0
0

Hi all In my WPF application I'm working with ListCollectionView as DataSource of my grid.This collection has big count of items (around 25000).
This collection is changed - items added and removed.
So I use ObservableCollection internally.
Sometimes during collection sorting I'm receiving the following exception that crashes whole my application

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index   
at System.Collections.Generic.List`1.get_Item(Int32 index)
   
at System.Collections.ObjectModel.Collection`1.System.Collections.IList.get_Item(Int32 index)
   
at System.Windows.Data.ListCollectionView.PrepareLocalArray()
   
at System.Windows.Data.ListCollectionView.RefreshOverride()
   
at System.Windows.Data.CollectionView.RefreshInternal()
   
at System.Windows.Data.CollectionView.DeferHelper.Dispose()
   
at Infragistics.Windows.DataPresenter.SortedFieldsToCollectionViewSynchronizer.UpdateCollectionViewSortAndGroupDescriptions()
   at Infragistics.Windows.DataPresenter.SortedFieldsToCollectionViewSynchronizer.SynchronizeHelper()   
--- End of inner exception stack trace ---
   
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   
at System.Delegate.DynamicInvokeImpl(Object[] args)
   
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

I tried to override RefreshOverride method of ListCollectionView    internalclassListCollectionViewExt:ListCollectionView   
   {
       ...
        protectedoverridevoid RefreshOverride()
        {
            try
            {  base.RefreshOverride();   }

            catch (Exception e)
            { // write log            }
        }   
   }

It did not help

I saw that error is inPrepareLocalArray method that called when performing DeferRefresh or Refresh methods It looks like it tries to access the item with index out of range – collection was changed during the sorting performed.

How can I handle it or find some work-around ? How can I override  PrepareLocalArray private method ?
Regards,


How to implement SCRAM-SHA1 authentication ?

$
0
0

How to implement SCRAM-SHA1 authentication ?

Please share the sample code if anyone have.

Get Value from Barcode scanner and dump into DB using WPF application

$
0
0
I am developing application in WPF C#. I am reading barcode from barcode scanner. Don't know how to get value in C# code that is read by scanner? Can someone help how to do this? Waiting for the positive reply. Thank you.

Add icons to toolbar of the wpf window

$
0
0

Hi,

I have a WPF window with windowStyle set to "SingleBorderWindow" which provides a close button on the right top corner

WindowStyle="SingleBorderWindow" 

I would like to add another button before the close button, say help button, settings button etc.,

Existing window looks like the following

 Current Window Toolbar

I would need a window toolbar like the following 

Any help to acheive this behaviour is highly appreciated.

Thanks in advance.


Double click on desktop icon is not launching WPF application

$
0
0

Hi,

Problem statement:

I have a WPF application which is in minimized state (visible in taskbar) and  when I double click on application desktop icon

application is not launching.

How do I  launch the application in above scenario.

Thanks

Vijay

Misbehaving WPF ComboBox

$
0
0

I have used comboBox before and has been extremely simple, however starting to use my new system decided to write a simple app that I can use for UI Automation.

The problem: Added a WPF comboBox to a simple application. Thought easy stuff right!  Spent the rest of the night trying to figure out this combobox. Handle the change even as such:

string item = comboBox.SelectedItem.ToString(); This passed the whole object to the textbox.   I just wanted the text value not the whole object name.  

Tried  string item = comboBoxSeleectedValue.ToString() and got the same result.

Tried comboBox.SelectionBoxItem.ToString() and got the text of the selection, however, it was displying an item lagging behind. In other words, when I selected 1st item displayed nothing.  When selected 2nd item it displayed first item and so on.

Weird!!!  The only way I got it to work was by googling around and found this which worked fine

ComboBoxItem item = comboBox.SelectedItem as ComboBoxItem;

 string item = item.Content.ToString();

Has anyone seen the this???  Using .net 4.5.2.  Visual Studio 2015.   Why something so simple was made so hard now?


NR


Visual studio 2015 Datagrid and list box question

$
0
0

Hi,

Ive got a WPF that interacts with an SQL DB using ADO.net, Ive got a script that fills a listbox with one item from database table, mainly because I haven't set up textblocks for other columns of the table.

I also have binded entries from the same table filling in a datagrid which works quite nicely, I'm trying to figure out how to get it so that when I click a ROW in either the listbox or the datagrid and display the information in a series of textboxes. right now i can only get it to put up nonsense database information or something about the database collection.

Ive tried all the toString stuff but it doesn't seem to work. I am using the listbox and datagrid because i haven't really decided which to use, the datagrid is easy to set up colums for etc but the listbox is supposed to be easier to mainupulate the data. Ive been looking online for a while and all i see is vb.net datagridview stuff.

Any help would be great

thanks guys

WPF StackPanel....

$
0
0

Hi guys.
Need some help with stackpanel control.What I want to do, is place a few controls inside and change their order during runtime using mouse events. I've implemented moving them along Y axis with mouse, but got problem with positioning.When I move them in designer,they position automatically-moving up and down as needed( desired behavior),but in my app I can drop control on top of another control which is not what i want.

Is there anything to get desired effect without 1k lines of code?

Cheers

Context menu item icon is not displaying in data template which is created in user control resource

$
0
0

Hi,

I have one user control. in user control resource have created two data template and both data template are used in view.

In data template I have created context menu and each context menu have item and icon.

Context menu header name is displaying but icon is not displaying.

In code Behind I have created property which I'm using to bind with image. Everything is working fine but only problem with icon.

so how to display the icon when context menu is created in data template.


vikas sharma AB

Changing out listview itemssource with multiple types at runtime

$
0
0

I'm not posting any code here, because I'm just looking for the broad strokes for how the thing I'm doing could be best organized--not help troubleshooting. It's pretty clear to me what I am doing wrong--but I cannot see how to do it right.

I have what I would call an MVVM application. An actual programmer might call it something much uglier than that. I have a class, MainWindowViewModel, which gets bound to the window and contains all kinds of functions that do the things that the window needs to do.

The most important property in the "MainWindowViewModel" is the AutoFilteredCollection<T>. There are 3. They contain the items to be displayed in a listview, Something Like

public AutoFilteredCollection<Dog> = DogCollection { get; set; }

public AutoFilteredCollection<Breed> = BreedCollection { get; set; }

public AutoFilteredCollection<Vet> = VetCollection { get; set; }

So Dog, Breed and Vet are related classes. But the most important thing they have in common is that they are in a SQLite database, and come into the model via Entity Framework. They also share an interface (IDBobject), which contains 2 properties: Name, and isIgnored. AutoFilteredCollection<T> contains SourceCollection<T> and FilteredCollection<T>, which allow users to sift through dogs or vets or whatever is up at the moment based on properties. So SourceCollection is an IEnumerable<T> with all of the objects, and FilteredCollection has the ones the user is looking for. But obviously the properties of dogs and vets are very different, so the interface can't really contain many of them.

It is very easy to bind the ListView ItemsSource directly to the FilteredCollection, or directly to on of the AutoFilteredCollections. But this bypasses the MainWindowViewModel, and so bypasses some of the functionality I've put into it. But switching between the 3 AutoFilteredCollections has proved very difficult (for me) because of the <T>. It is just very difficult to swap 3 IEnumerables with different <T> in and out of the same listview without just setting the itemssource or datacontext of the listview separately from the rest of the window.

I have spent a lot of time (A. Lot. Of. Time.) trying to do this by making everything AutoFilteredCollection<IDBObject>, but C# really doesn't seem to like that And the only way it works is if IDBobject has every single property users might want to sort by, which is pointless.

I have also thought of abandoning trying to swap the different IEnumerable types into the listview and come up with some solution involving tabs.

So while this has all been a magnificent lesson in how IEnumerable<T> works, I was hoping that some professional could propose a really clean solution, or at least bless my tabs idea before I get too deep into it.

I have a wpf form in which , i have a datagrid with autogenerate colounms =true and a button to refresh the datagrid data,I also have a dock panel in which i am addina a usercontrol to it ...On click of a button in usercontrol, i am trying to click

$
0
0
I have a wpf form  in which  , i have a datagrid with autogenerate colounms =true   and a button to refresh the datagrid data,I also have a dock panel in which i  am addina a usercontrol to it ...On click of a button in usercontrol, i  am trying to  click the refresh button to refresh the datagrid data , the button click is firing but the datagrid is not refreshing, has anyone encountered such problem please help

Graphical Paths with Gradient Colors

Problem with resource

$
0
0

Hello. I have a control template like that.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    xmlns:controls="clr-namespace:GraphLibrary.MVVM.Controls"
                    mc:Ignorable="d"><Style TargetType="{x:Type controls:Curve}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type controls:Curve}"><ControlTemplate.Resources><PathGeometry x:Key="BezierGeometry"><PathGeometry.Figures><PathFigure x:Name="BezierFigure" StartPoint="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=point0}"><BezierSegment Point1="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=point1}"
                                                       Point2="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=point2}"
                                                       Point3="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=point3}"/></PathFigure></PathGeometry.Figures></PathGeometry></ControlTemplate.Resources><Grid><Path Stroke="{TemplateBinding Background}" StrokeThickness="{TemplateBinding Thickness}" Data= {StaticResource BezierGeometry}"></Path></Grid></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>

It gives warning "Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=StartPoint; DataItem='Curve' (Name=''); target element is 'PathFigure' (HashCode=51607035); target property is 'StartPoint' (type 'Point')" and doesn;t work. But if I embed PathGeometry inside Path tag then it works fine.

What is wrong with it?




changing the datasources of datagrid dynamically.

$
0
0

Hi, 

  I have a listbox which will list the all the tables from my DB. Some fo the tables are listed below.

eg., Employee( EmpoyeeId, LoginId, JobTitle, FirstName,.... ), Department ( DeptId, DeptName, GroupName), Shift (ShiftId, Name, StartTime,EndTime) and many more tables.

I use MVVM pattern and my Viewmodel has all the tables as observable collection (ObservableCollection<Employee> EmployeeCollection, ObservableCollection<Department> DepartmentCollection etc).

I will be having a grid next to my listbox. On clicking the table name, I will be retrieving all the records of the selected table and filling in the observable collection.  How can I bind the retrieved values to my grid. As the column name varies for each table, do I need to use that many grids or is there a better way to bind the values to the grid.

Thanks,

Sanjay.

  

Is there an attribute like DesignOnly but RunTimeOnly

$
0
0

Hello everyone,
I would like to implement an inherited class where one of its property should be available only at runtime.
I don't want that the designer takes into account the property due to I get an exception (At run time works good).

May you help me?

Thank you in advance.

public class SharedResourceDictionary : ResourceDictionary { public static Dictionary<Uri, ResourceDictionary> gSharedDictionaries = new Dictionary<Uri, ResourceDictionary>(); public bool IsInDesignMode { get { return (bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(DependencyObject)).Metadata.DefaultValue; } }

private Uri gSource;

[RunTimeOnlyAttribute] --> I need the attribute here public new Uri Source { get { //if (IsInDesignMode) { return base.Source; } return gSource; } set { if (gSource == value) { return; } gSource = value; if (!gSharedDictionaries.ContainsKey(value)) { base.Source = value; gSharedDictionaries.Add(value, this); } else { MergedDictionaries.Add(gSharedDictionaries[value]); } } } }


How to get the rendered input type="text" element from a System.Windows.Controls.WebBrowser in WPF

$
0
0

Hi there,

I'm just new to WPF development.  And, one of the XAML file that I'm working with is that there is a WebBrowser object which belongs from the namespace System.Windows.Controls.  With that, the browser will navigate to a new Uri (i.e. https://wego.here.com/?x=ep&amp;map=-36.85,174.765,10,normal) and, once the document (map) is loaded the user can perform search of address from the rendered input box (search input box where a user can search for an address).

My goal is that, I want to trigger an event once the search input box got the focus.  However, System.Windows.Controls.WebBrowser doesn't have an event handler DocumentCompleted which I can easily trigger.  This event handler is only available in System.Windows.Forms.WebBrowser. 

Is there a way or any event handler which I can leverage on System.Windows.Controls.WebBrowser?  If there is, does WebBrowser.Document contains the rendered elements?

Any inputs or help to provide some insights are highly appreciated.

Cheers,


Code Runner

How to detect if point is within the boundary of a control, following transformations?

$
0
0
I have a WPF application that is communicating with a touch screen controller. The XY coordinates are fed into the PC via USB and this triggers an event inside my WPF code. Currently I draw an elipse on the WPF screen to show the posistion of my co-ordinate, this works fine.

 I also have a WPF image on my application and I want to drag and drop this. Now I could just check if X > image1.Location.X and < image1.location.X + image1.ActualWidth

(same for Y) to find out if it is within the rectangular area that my image is draw in.

However this stops working if apply a rotate transform to the image. Is there any function in WPF where I can feed in my coordinate and I can get a bool to tell me if the point was within the boundaries of the control, or if 2 shapes intersect each other?

I have searched everywhere and there seems to be no easy answer.

Dan

Set Current caretposition in WPF richtextbox center?

$
0
0

I already used the below code. It moves current caret position in viewport top.

FrameworkContentElement fce = (tpNextLine2.Parent as FrameworkContentElement);
if (fce != null)
{
    fce.BringIntoView();
}

the another method is,

rtb.ScrollToVerticalOffset(rc.Top + rtb.VerticalOffset);

I want to Set current caretposition textpointer in richtextbox  Center  top position,i mean move each word from center to left side using WPF. And also highlight that caret position word  in the center top position of the richtextbox. 

How can I achieve this?

Regards

Sanju

Viewing all 18858 articles
Browse latest View live


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