Manipulation events not triggering on Templated Control [UWP] - xaml

I am trying to implement a custom control (Templated Control) for a UWP application for transforming shapes (mostly Rectangle types). Custom control will be implemented in a UWP class library and reference to the main project. What I want to achieve is draw the custom control around another basic shape (eg: Rectangle) and transform the shape according to the manipulations done on the custom control.
I am trying to implement the control with manipulation events (ManipulationDelta, ManipulationCompleted).
I was able to achieve a similar behavior using pointer related events(PointerPressed, PointerMoved, PointerReleased) but it is not very smooth & I want to integrate this control with other applications easily.
Please find the sample source code here.
When I try to move the control the manipulation events are not firing, and I cannot figure out the reason.
I started to work on UWP applications recently and any help on this matter is highly appreciated.

In your scenario, there are several removing codes in PointPressed event, such as “RootCanvas.Children.Remove()”. When you move the control, the PointPressed event is triggered, the previous generated rectangle named resizableRectV2 is deleted. So the resizableRectV2.ManipulationCompleted event will not be triggered.
In addition, I suggest that you don’t create two completely overlapping rectangles, which makes you confused.
Update:
SpeakerView.xaml.cs:
RootCanvas.Children.Remove(RootCanvas.Children.Where(x => x.GetType() == typeof(ResizableRectangle)).FirstOrDefault());
I mean that you could delete the above code in OnPointerPressed event.

Related

Add custom control to toolbox and have its properties show up in the properties window

To illustrate what I'm asking, let's say I have a custom TextBox that has 2 modes. Mode 1 only allows numbers, and mode 2 only allows dates in a particular format.
Using a class module I can create this custom TextBox, and I can use a loop when the userform initialises to set which TextBoxes are custom.
What I'd like to happen is have the custom TextBox, or what ever custom control I want, show up in the toolbox. And I also want its custom properties, if they exist, to show up in the property window.
So far, I've been unable to find a way to do this. In fact, I've been unable to find out if it's even possible. It seems, to me anyway, that it's something that should be possible, but maybe I'm barking up the wrong tree. If it's possible I'd really appreciate being pointed to a resource.

undo for non textbox controls

new to .net coming from vba decided to rewrite a management app using vb.net and SQL Server.
Started writing the base library for my application.
I created custom controls to use in my application that would expose a Zoom function, background color for the current active control a .modified property similar to the one available in textbox and some extra other properties (SQLTableName, SQLColumnName, ...) to enable iterating through a container (form) for modified controls and Update/Insert into a SQL table via a SQLProcessClass.
Concurrently I'd like to also implement a simple undo functionality.
My first idea was to add a PrevValue variable set in the OnEnter event if the Modified property is False, exposing an OldValue property and an Undo method in the custom controls.
However I found that the TextBoxBaseClass already exposes an Undo method and that there is an UndoEngineClass available.
Unfortunately the vs helpfile does not give examples of how to use / implement that class.
Could someone explain the usage of the UndoEngine class non-textbox controls and if it is advisable to use it or rather write my own (as I first intended to do - I also found some interesting articles about undo/redo classes) but why reinvent the wheel in case .net already provides a class for it.
thks

Which control should be used for a scheduler and how?

I'm trying to do a scheduler for a lesson schedule. Which control should I use and how to do?
Here you find an image of what I'm trying.
You should create a UserControl based on the "DatePicker" control.
And then redefine the control template, using a UniformGrid.
There is no simple and quick way to do that yourself. Either you recreate a custom control based on a DatePicker, or you try to find a library of controls already doing what you are trying to.
I believe a few controls already exists to do that, but I don't have names to throw in.

AutomationPeer - how to show data of elements not on the control?

I want to write an AutomationPeer for my custom control in WPF.
Now, I want to show textBlocks \ TextBoxex that are not actually visible on my control.
I know how to override the method GetChildrenCore().
My problem is that when i run the playback (coded ui record) - it's trying to find a control not vissible on the window. Have you got any ideas?
You can set the SearchConfiguration VisibleOnly on the Coded UI control. Also, the UITestControl.FindMatchingControls method can let you know if the search properties are too ambiguous. Coded UI stops looking for a control after the first instance of a matching control is found.
inspect.exe can shed light on a form and how Coded UI may be seeing the control.
Try opening the Designer.cs and see the hierarchy and what Coded UI is trying to find.

Cannot add new controls when creating a composite user control

I am trying to broaden my knowledge of user controls or to be more specific, composite user controls. Msdn has a walkthrough on the subject here which although not in VB is easy enough to follow and get results.
What I had had in mind was to create a base user control comprised of a split panel, one half of which would be used to display dynamic help and the other half which could house whatever controls the new user control which would inherit from this required. The problem that I am facing is that when I then create a new inherited control based upon my base control I cannot add new controls to the design surface. If I don't have a split panel filling the entire design surface of the base control I can add new controls, but if I do I can't.
Either I am doing something wrong, or more likely failing to do something on the base control that I ought to do , or this can't be done which I find odd to believe. I'm hoping someone can explain what it is I've missed.
This is being targeted at winforms with vb.
Thanks
Well, Did you make the split panel's modifier to protected or protected internal or public? That should do the trick.
By default it is private and so designer will prevent you from accessing it.