|
Can't you get the position and size of the containing element (canvas) in relation to the window and massage those values into you control position.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I can get a reference to the Canvas, but it doesn't have Left or Top properties.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I describe, is the Edge Browser window tab, drag and drop out to generate a new form, the drag process mouse followed by a label image. What can I do to achieve a similar drag-and-drop operation?
What can I do to achieve the following functions, do you really want to use the mouse hook, Microsoft itself should not be in the UWP program to use Win32 things.
The main thing is that WPF mouse-moving event cannot be triggered outside the window.
|
|
|
|
|
|
This project doesn't solve the problem I'm asking, I need to drag a control or item out of the window and create a new window.
|
|
|
|
|
Maybe you're using the "wrong gesture".
"Drag and drop" is not something one associates with "creating a new window".
One "creates a window" and then "places" it somewhere; not the other way around (dragging "something" that "spawns" a window).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It's a common UI trick used in applications such as Chrome and Visual Studio. A tab is dragged out of the app to create a new shell.
This space for rent
|
|
|
|
|
Sure; but what we "see" happening may have no bearing on the actual implementation.
He wants to "drag a control" outside the scope of the application.
If instead he used a "proxy" window, he could accomplish what he wanted.
But if one is only fixated on the "image of a control" ...
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
So you have the right example or demo, and I want to see how it works.
|
|
|
|
|
The way to handle this is to have the window itself act as the drop target. When the DragLeave[^] event is raised, create a new Window and add that tab into that window. There's a lot of code that you're going to have to write here - when I've done it, I've written it for clients so they own that code so I can't share it with you. You can see from this what you need to do so you should be able to cope with the actual mechanics of it yourself.
This space for rent
|
|
|
|
|
Hi, maybe everybody can help me with Dependency Properties and a custom Control, this costumer Control contains a grid, the grid shall be created progammatically- new columns with Buttons and external controls.
I have a dependency properties in this custom Control, but when i call the custom Control then the grid doesn't change.
It seems I have no accessto the grid? Because nothing will created in the grid, no column, no button. What do I wrong?
What I have tried:
my dependency property :
public static DependencyProperty Symbol1Name =
DependencyProperty.Register("Sym1Name", typeof(string), typeof(UserControl1), new FrameworkPropertyMetadata("test", OnSymbol1PropertyChanged))
public string Sym1Name
{
get { return (string)this.GetValue(UserControl1.Symbol1Name); }
set { this.SetValue(UserControl1.Symbol1Name, value); }
}
The onChange Function
private static void OnSymbol1PropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
UserControl1 ak = dependencyObject as UserControl1;
ak.OnPropertyChanged("Symbol1Name");
ak.OnSymbol1PropertyChanged(e);
}
The function to Change works in normal WPF App:
private void OnSymbol1PropertyChanged(DependencyPropertyChangedEventArgs e)
{
try
{
change(Sym1Name, 0);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
The XAML:
<Grid x:Name="Grid1" Grid.Column="1" Background="Gray" Margin="5,0,0,0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>
|
|
|
|
|
|
It is possible to show group summary rows in a standard WPF Data Grid? I've been Googling and I can't see to find what I'm looking for.
Do I need a third party grid for this? If so, any suggestions?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: It is possible to show group summary rows I presume you mean Sub Total rows - not sure if the standard DG will do it but the Telerik one certainly does.
Actually I will bet every commercial DG will have that feature.
Google foo wpf datagrid grouping subtotal - Google Search[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks. I was hoping to not have to buy one.
BTW, why did you post a Google search? Not sure what that's for when I already said I Googled it.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: I already said I Googled it Missed that and it looked like there was some reasonable hacks to the standard DG. I have used Gerry's suggestion in the past, inserting total rows manually, it may not be grouping but you do get the sub totals.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Calculate group total objects and add them to the data grid's data source (at the end of each group). Add a type code and style accordingly; or use a template selector.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
The subject really say it all, even if it sounds over-complicated. Please hang on.
I have a DataGrid. There are several columns in the DataGrid.
One of the columns contains a ListView. The listView holds several rows.
Each row contains a TextBlock and a Button.
The TextBlock's Text property contains a name, which I want to pass to my ViewModel.
I have managed to create a small example of this which should be just to "copy-paste-run".
Since it is "a lot" of code I have made a public gist to store it in.
Link to source in GIT Gist[^]
Setup:
* I use Visual Studio 2015 and compiling to NET 4.5.2.
* I also use Fody.PropertyChanged, then I'm not needed to manually type all stuff required for the INotifyPropertyChanged interface.
* Create a new WPF application and call it: WpfTest.
* Save the project.
* Install the Fody.Propertychanged in the NuGet Package Manager.
* Create the FodyWeavers.xml file.
* Paste all code from the Gist.
Note:
If the compiler says: "Fody: Could not find a weaver named 'PropertyChanged'. ..."
Remove the <PropertyChanged /> from the FodyWeaver.xml file and try again. That line is not neccessary for this and I don't understand why it sometimes fail when compiling.
This is what I want
If you click any of the buttons in the DataGrid I want the associated name on the same row in the ListView to be bound to the SelectedName property in the ViewModel.
I have no clue how to do the binding of the selected Textblock's Text property to the ViewModel in the View's xaml code.
For example: Press the button to the right of NameA. I then want my ViewModels SelectedName to be "NameA".
I tried this in the ListView, but no luck:
<ListView ItemsSource="{Binding Names}" SelectedItem="{Binding SelectedName}">
I also tried this, with no luck:
<ListView ItemsSource="{Binding Names}" SelectedItem="{Binding Path=DataContext.SelectedName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}">
Please, how can I do this?
P.S
I can kinda get this to work by binding the SelectedItem property from the DataGrid and the SelectedIndex property from the ListView. But that feels like a work-around.
|
|
|
|
|
No sympathy.
- Add a click handler / delegate that "stuffs" the "selection"; i.e. "code behind". (It's PLUMBING).
- And you don't need all that "property changed stuff". If you know you are refreshing all controls on a container, you can call propertychanged with "no name" (on the container) and refresh all with one statement. You need a really "slow" machine for individual "property changed" events to make a difference.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi everybody,
I would like to set a background image to a Groupbox and have it displayed at run time.
Below are the lines inserted in the xaml file at the appropriate locations:
<Window.Resources>
<VisualBrush x:Key="myNewBrush">
<VisualBrush.Visual>
<Grid>
<Rectangle Fill="Transparent"/>
<Image Source = "/Resources/Images/BartMap.png"/>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Windows.Resources>
<GroupBox Grid.Row="1" Grid.Column="0" Background="Transparent">
<GroupBox.Header>
<Label FontWeight="Bold">Track plan </Label>
</GroupBox.Header>
<Grid Background="{StaticResource myNewBrush}">
</Grid>
</GroupBox>
My problem: The image background is not displayed at runtime.
Could anyone help me with this issue?
Best regards,
|
|
|
|
|
I copied your code into a project and ran it successfully. The only thing that's different in my version is that I have a different image (obviously). Check that the image is set to a Build Action of Resource and that Copy To Output Directory is set to Do Not Copy. My successful code:
<Window x:Class="WpfSample.MainWindow"
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:local="clr-namespace:WpfSample"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<VisualBrush x:Key="myNewBrush">
<VisualBrush.Visual>
<Grid>
<Rectangle Fill="Transparent"/>
<Image Source = "real-sense-images.png" />
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Window.Resources>
<Grid>
<GroupBox Background="Transparent">
<GroupBox.Header>
<Label FontWeight="Bold">Track plan</Label>
</GroupBox.Header>
<Grid Background="{StaticResource myNewBrush}"/>
</GroupBox>
</Grid>
</Window>
This space for rent
|
|
|
|
|
Hi Pete,
Thank you for your reply.
I'm wondering if you could precise a little bit what you mean by: "<i>Check that the image is set to a Build Action of Resource and that Copy To Output Directory is set to Do Not Copy</i>".
Best regards,
Hervend
|
|
|
|
|
I've checked and the two settings have the default values you specified.
Up to now I don't understand what's going on.
Hervend
|
|
|
|
|
Thank you all for your replies.
I have set the property Copy To Output Directory to Always Copy.
And everything seems now to be in order.
thank you for your support.
Hervend
|
|
|
|
|
Would you not be better off creating a style element:
<GroupBox Grid.Row="4" Header="Test" BorderBrush="Black" BorderThickness="1">
<GroupBox.Style>
<Style TargetType="GroupBox">
<Setter Property="Background" Value="{StaticResource myNewBrush}"/>
</Style>
</GroupBox.Style>
<Button Grid.Row="0" Name="_buttonPressMe" Content="Press me!" Click="_buttonPressMe_Click" Width="80"/>
</GroupBox>
Obviously the layout in the above is rubbish, but the background is set correctly. I tested this in a demo app and it ran fine.
|
|
|
|