Click here to Skip to main content
14,331,628 members

Silverlight / WPF

 
Questiondeployment size with WPF on .NET Core Pin
Super Lloyd2-Jun-19 14:47
memberSuper Lloyd2-Jun-19 14:47 
AnswerRe: deployment size with WPF on .NET Core Pin
Mycroft Holmes2-Jun-19 16:02
memberMycroft Holmes2-Jun-19 16:02 
GeneralRe: deployment size with WPF on .NET Core Pin
Super Lloyd2-Jun-19 16:44
memberSuper Lloyd2-Jun-19 16:44 
GeneralRe: deployment size with WPF on .NET Core Pin
Gerry Schmitz5-Jun-19 6:49
mveGerry Schmitz5-Jun-19 6:49 
GeneralRe: deployment size with WPF on .NET Core Pin
Super Lloyd5-Jun-19 14:26
memberSuper Lloyd5-Jun-19 14:26 
AnswerRe: deployment size with WPF on .NET Core Pin
Eddy Vluggen6-Jun-19 0:10
mveEddy Vluggen6-Jun-19 0:10 
GeneralRe: deployment size with WPF on .NET Core Pin
Super Lloyd6-Jun-19 0:52
memberSuper Lloyd6-Jun-19 0:52 
AnswerWPF ListBoxView Problem Pin
Alisaunder23-May-19 2:17
memberAlisaunder23-May-19 2:17 
I' making a very simple app to drag files from my desktop or explorer into a WPF ListBoxView, these files will be auto backed up on a specific day and time. I have the dragging files into the ListBoxView working fine. Can even insert Multiple selected at one time. I can rearrange my list order by dragging and dropping fine as well. My issue is I can't seem to trigger it to remove the file I drag out of the ListBoxView control to remove it from the List. Can anyone help ??

My Xaml
<Label Grid.Row="0" Content="Files to be copied..." Background="{x:Null}" Foreground="White" HorizontalAlignment="Center"/>
        <ListBox Grid.Row="1"

                 x:Name="dropList"

                 Margin="10"

                 SelectionMode="Extended"

                 AllowDrop="True" 

                 Drop="DropList_Drop" 

                 Foreground="White"

                 Background="#FF333337"

                 Height="Auto"

                 Width="Auto"

                 VerticalAlignment="Stretch"

                 MouseMove="DropList_MouseMove"

                 PreviewDragLeave="DropList_PreviewDragLeave" >            
            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem x:Name="Options"

                              Header="Options..."

                              Click="Options_Click"

                              Foreground="Black"/>
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>  

My C#
private void DropList_Drop(object sender, DragEventArgs e)
        {            
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                foreach (string data in files)
                {
                    if (!dropList.Items.Contains(data))
                        dropList.Items.Add(data);
                }
            }
            else
            {
                object data = e.Data.GetData(typeof(string));
                dragSource.Items.Remove(data);
                dropList.Items.Add(data);
            }
        }

        private void DropList_MouseMove(object sender, MouseEventArgs e)
        {
            // Get the current mouse position
            Point mousePos = e.GetPosition(null);
            Vector diff = startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                dragSource = dropList;
                object data = GetDataFromListBox(dragSource, e.GetPosition(dropList));

                if (data != null)
                {
                    DragDrop.DoDragDrop(dropList, data, DragDropEffects.Move);
                }
            }
        }

        private void DropList_PreviewDragLeave(object sender, DragEventArgs e)
        {
            if (Mouse.LeftButton == MouseButtonState.Released)
            {
                dragSource = dropList;
                object data = GetDataFromListBox(dragSource, e.GetPosition(dropList));

                if (data != null && dropList.Items.Contains(data))
                    dropList.Items.Remove(data);
            }            
        }


modified 23-May-19 13:01pm.

AnswerRe: WPF ListBoxView Problem Pin
Gerry Schmitz23-May-19 3:31
mveGerry Schmitz23-May-19 3:31 
AnswerRe: WPF ListBoxView Problem Pin
Alisaunder23-May-19 7:19
memberAlisaunder23-May-19 7:19 
GeneralRe: WPF ListBoxView Problem Pin
Gerry Schmitz23-May-19 7:44
mveGerry Schmitz23-May-19 7:44 
QuestionWPF Geometry Question Pin
Kevin Marois9-May-19 9:56
professionalKevin Marois9-May-19 9:56 
AnswerRe: WPF Geometry Question Pin
Richard Deeming9-May-19 10:14
mveRichard Deeming9-May-19 10:14 
GeneralRe: WPF Geometry Question Pin
Kevin Marois9-May-19 10:25
professionalKevin Marois9-May-19 10:25 
QuestionDataGrid Binding Problem Pin
Kevin Marois29-Apr-19 17:37
professionalKevin Marois29-Apr-19 17:37 
AnswerRe: DataGrid Binding Problem Pin
Gerry Schmitz29-Apr-19 18:22
mveGerry Schmitz29-Apr-19 18:22 
GeneralRe: DataGrid Binding Problem Pin
Kevin Marois30-Apr-19 4:34
professionalKevin Marois30-Apr-19 4:34 
GeneralRe: DataGrid Binding Problem Pin
Gerry Schmitz30-Apr-19 5:43
mveGerry Schmitz30-Apr-19 5:43 
GeneralRe: DataGrid Binding Problem Pin
Kevin Marois30-Apr-19 6:47
professionalKevin Marois30-Apr-19 6:47 
GeneralRe: DataGrid Binding Problem Pin
Gerry Schmitz30-Apr-19 21:46
mveGerry Schmitz30-Apr-19 21:46 
AnswerRe: DataGrid Binding Problem Pin
Mycroft Holmes29-Apr-19 21:19
memberMycroft Holmes29-Apr-19 21:19 
GeneralRe: DataGrid Binding Problem Pin
Kevin Marois30-Apr-19 4:35
professionalKevin Marois30-Apr-19 4:35 
GeneralRe: DataGrid Binding Problem Pin
Mycroft Holmes30-Apr-19 12:25
memberMycroft Holmes30-Apr-19 12:25 
AnswerRe: DataGrid Binding Problem Pin
Richard Deeming1-May-19 8:32
mveRichard Deeming1-May-19 8:32 
QuestionBinding "SelectedItems" of a Listbox Pin
Jayme6524-Mar-19 1:15
memberJayme6524-Mar-19 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.