IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

problème datagrid (débutant)


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 8
    Par défaut problème datagrid (débutant)


    Bonjour, j'ai un problème avec ma datagrid, j'utilise un wrapper pour récupérer la liste de mes torrent et le wpftoolkit en téléchargement dans utorrent
    lorsque j'ajoute un torrent, la data grid d'actualise sans problème
    par contre quand j'en enleve un, j'obtiens cette exception, merci d'avance de votre aide.

    un autre problème lorsque j'ai plsu de 9 item dans ma data grid , j'ai un bug d'affichage sur la première colonne de ma data grid, par contre quand je bouge la sélection sur un élement plsu de bug sur l'élement sélectionné





    exeption here

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    Code:
    L'exception System.Reflection.TargetInvocationException n'a pas été gérée
      Message="Une exception a été levée par la cible d'un appel."
      Source="mscorlib"
      StackTrace:
           à System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           à System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           à System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           à System.Delegate.DynamicInvokeImpl(Object[] args)
           à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           à System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           à System.Windows.Threading.DispatcherOperation.InvokeImpl()
           à System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           à System.Threading.ExecutionContext.runTryCode(Object userData)
           à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Windows.Threading.DispatcherOperation.Invoke()
           à System.Windows.Threading.Dispatcher.ProcessQueue()
           à System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
           à System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           à System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
           à System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
           à System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
           à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           à System.Windows.Threading.Dispatcher.Run()
           à System.Windows.Application.RunDispatcher(Object ignore)
           à System.Windows.Application.RunInternal(Window window)
           à System.Windows.Application.Run(Window window)
           à System.Windows.Application.Run()
           à WpfApplication2.App.Main() dans C:\Users\Vinzzz\Documents\Visual Studio 2008\Projects\WpfApplication2\WpfApplication2\App.cs:ligne 119
           à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.InvalidOperationException
           Message="L'événement CollectionRemove doit spécifier la position de l'élément."
           Source="PresentationFramework"
           StackTrace:
                à MS.Internal.Data.EnumerableCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args)
                à System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
                à Cleverscape.UTorrentClient.WebClient.TorrentCollection.CallCollectionChangedAsync(NotifyCollectionChangedEventArgs EventArgs)
           InnerException:

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    2 210
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 210
    Par défaut
    Salut,

    Pour tes deux problèmes, il faudrait que tu mettent un peu de code :
    • le code que tu utilises pour la suppression d'un élément (l'exception ne me parle pas...)
    • le code du Template que tu utilises pour ta première colonne, voir carrément tout le style de la datatgrid

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 8
    Par défaut
    voici pour le xaml
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    <UserControl
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication2"
        xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="WpfApplication2.Window1"
        Height="240" Width="320" mc:Ignorable="d">
        <UserControl.Resources>
           <local:TimeSpanDisplayConverter x:Key="TimeSpanConvert" />
            <local:QueuePriorityDisplayConverter x:Key="QueuePriorityConvert" />
            <local:SizeBytesDisplayConverter x:Key="SizeConverter" />
            <local:SizeBytesShowZeroDisplayConverter x:Key="SizeShowZeroConverter" />
            <local:SpeedBytesDisplayConverter x:Key="SpeedConverter" />
            <local:SeedPeerRatioDisplayConverter x:Key="SeedPeerRatioConverter" />
            <local:StatusDisplayConverter x:Key="StatusConverter" />
            <local:StatusImageDisplayConverter x:Key="StatusImageConverter" />
     
            <Style x:Key="{x:Type ProgressBar}" TargetType="{x:Type ProgressBar}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ProgressBar}">
                            <Grid MinHeight="14" MinWidth="50">
                                <Border x:Name="PART_Track" CornerRadius="0" Background="#00FFFFFF" BorderBrush="#FFF0F0F0" BorderThickness="1" />
                                <Border x:Name="PART_Indicator" CornerRadius="0" Background="#FFA0A0FF" BorderBrush="#00FFFFFF" BorderThickness="0" HorizontalAlignment="Left" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </UserControl.Resources>
     
        <Grid>
     
            <my:DataGrid Name="DataGridTorrents" Margin="0,36,0,0" AutoGenerateColumns="False" ItemsSource="{Binding}" BorderThickness="0" GridLinesVisibility="None" 
                         RowDetailsVisibilityMode="Collapsed" FontSize="11.5" HorizontalGridLinesBrush="Transparent" VerticalGridLinesBrush="Transparent" VerticalContentAlignment="Center" VerticalScrollBarVisibility="Visible" SelectedIndex="0">
                <my:DataGrid.Columns>
                    <my:DataGridTemplateColumn Header="Name" SortMemberPath="Name" IsReadOnly="True" >
                        <my:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel CanHorizontallyScroll="False" CanVerticallyScroll="False" FlowDirection="LeftToRight" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal" >
                                    <Image Height="16" Width="16" Source="{Binding Mode=OneWay, Path=SimpleStatus, Converter={StaticResource StatusImageConverter}}" />
                                    <TextBlock Text="{Binding Mode=OneWay, Path=Name}" />
                                </StackPanel>
                            </DataTemplate>
                        </my:DataGridTemplateColumn.CellTemplate>
                    </my:DataGridTemplateColumn>
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=QueueOrder, Converter={StaticResource QueuePriorityConvert}}" Header="#" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeTotalBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Size" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeDownloadedBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Downloaded" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeRemainingBytes, Converter={StaticResource SizeConverter}}" Header="Remaining" IsReadOnly="True" />
                    <my:DataGridTemplateColumn Header="Done" SortMemberPath="ProgressPercent" IsReadOnly="True" >
                        <my:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid>
                                    <ProgressBar BorderThickness="1" BorderBrush="#FFF0F0F0" Maximum="1" Minimum="0" Value="{Binding Mode=OneWay, Path=ProgressPercent}" Background="White" Foreground="#FF5050FF" SmallChange="0.001">
                                    </ProgressBar>
                                    <TextBlock Text="{Binding Mode=OneWay, Path=ProgressPercent, StringFormat=0.0%}" TextAlignment="Center" />
                                </Grid>
                            </DataTemplate>
                        </my:DataGridTemplateColumn.CellTemplate>
                    </my:DataGridTemplateColumn>
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SimpleStatus, Converter={StaticResource StatusConverter}}" Header="Status" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Seeds}" SortMemberPath="SeedsTotal" Header="Seeds" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Peers}" SortMemberPath="PeersTotal" Header="Peers" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SeedsPeersRatio, Converter={StaticResource SeedPeerRatioConverter}}" Header="Seeds/Peers" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SpeedDownloadBytes, Converter={StaticResource SpeedConverter}}" Header="Down Speed" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SpeedUploadBytes, Converter={StaticResource SpeedConverter}}" Header="Up Speed" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=TimeEstimate, Converter={StaticResource TimeSpanConvert}}" Header="ETA" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SizeUploadedBytes, Converter={StaticResource SizeShowZeroConverter}}" Header="Uploaded" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=SeedRatio, StringFormat=0.000}" Header="Ratio" IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Availability, StringFormat=0.000}" Header="Avail." IsReadOnly="True" />
                    <my:DataGridTextColumn Binding="{Binding Mode=OneWay, Path=Label}" Header="Label" IsReadOnly="True" />
                </my:DataGrid.Columns>
            </my:DataGrid>
     
            <Image x:Name="image1" Stretch="Fill" Height="36" VerticalAlignment="Top" Source="Resources/utmenu.png" />
     
            <TextBox Height="36" x:Name="textBox1" VerticalAlignment="Top" d:IsHidden="True" Margin="142,0,0,0" Background="Transparent" BorderThickness="0" Foreground="White" />
     
        </Grid>
    </UserControl>
    pour le code behind
    en se qui concerne le remove je ne fait rien niveau code, le datacontext j'actualise tout seul mais la datagrid semble ne pas suivre par contre à l'ajout pas de soucie

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     public Window1()
            {
                InitialiseUTorrent();
                InitializeComponent();        
     
            }
     
            private void InitialiseUTorrent()
            {
     
                uTorrent = new UTorrentWebClient(_uTorrentAddress, _uTorrentUserName, _uTorrentPassword,true,Dispatcher);
     
                DataContext = uTorrent.Torrents;
                uTorrent.TorrentsUpdated += new EventHandler(uTorrent_TorrentsUpdated);
                uTorrent.TorrentAdded += new TorrentEventHandler(uTorrent_TorrentAdded);
     
     
            }

  4. #4
    Membre Expert
    Profil pro
    Inscrit en
    Décembre 2004
    Messages
    2 210
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2004
    Messages : 2 210
    Par défaut
    Pour le problème d'affichage, essaie d'utiliser un autre conteneur que le StackPanel au niveau du template de la première colonne. Exemple avec un DockPanel :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
                        <my:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <DockPanel CanHorizontallyScroll="False" CanVerticallyScroll="False" FlowDirection="LeftToRight" HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal" >
                                    <Image DockPanel.Dock="Left" Height="16" Width="16" Source="{Binding Mode=OneWay, Path=SimpleStatus, Converter={StaticResource StatusImageConverter}}" />
                                    <TextBlock Text="{Binding Mode=OneWay, Path=Name}" />
                                </DockPanel>
                            </DataTemplate>
                        </my:DataGridTemplateColumn.CellTemplate>

    Par contre pour la suppression, je ne comprend pas trop comment tu procèdes...

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mai 2010
    Messages
    8
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2010
    Messages : 8
    Par défaut
    pas mieux, seul le name de la dernier colonne s'affiche les autre non
    sélectionner ou pas merci de ton aide
    pour le remove j'ai une collection de torrent dnas un datacontext lui meme relier a la datagrid lorsque un torrent est ajouter dans la collection pas de probleme mais quand j'en supprime un, il se supprime de la collection mais l'application plante

Discussions similaires

  1. requete, problème de débutant
    Par focus dans le forum Access
    Réponses: 4
    Dernier message: 16/02/2006, 05h51
  2. Problème de débutant dans une requête
    Par decour dans le forum Access
    Réponses: 7
    Dernier message: 14/10/2005, 14h17
  3. [C#][service windows] problème de débutant avec 1 timer
    Par Nycos62 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 14/10/2005, 11h22
  4. Réponses: 3
    Dernier message: 24/09/2005, 09h34
  5. [DB2] problèmes de débutant
    Par rémi_tounul dans le forum DB2
    Réponses: 4
    Dernier message: 21/04/2005, 17h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo