<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[WPF - ListView]]></title><description><![CDATA[<p dir="rtl">השאלה שלי איך משנים בזמן ריצה את התמונה המופיעה בכל שורה ב ListView ?</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 08:31 (+03:00)</em></p>
]]></description><link>https://tchumim.com/topic/186/wpf-listview</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 17:38:53 GMT</lastBuildDate><atom:link href="https://tchumim.com/topic/186.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 29 Jan 2018 10:33:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:34:00 GMT]]></title><description><![CDATA[<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A8%D7%97%D7%9E%D7%99%D7%9D" aria-label="Profile: רחמים">@<bdi>רחמים</bdi></a></p>
<blockquote>
<p dir="rtl">זה ממש נפלא כעת! האיקונים מוסיפים המון.<br />
רק הבעיה שהם לא חדים אע''פ שהם מוצגים ברזולוציה המקורית שלהם, אותו דבר ב WINFORMS היא נראה יותר חד, יש מה לעשות עם זה?</p>
</blockquote>
<p dir="rtl">מעניין. תנסה סתם תמונה אחרת.</p>
<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%A8%D7%97%D7%9E%D7%99%D7%9D" aria-label="Profile: רחמים">@<bdi>רחמים</bdi></a></p>
<blockquote>
<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%93%D7%95%D7%93" aria-label="Profile: דוד">@<bdi>דוד</bdi></a> ל.ט.<br />
מעניין אותי איך הצלחת להכניס ערכים טקסטואליים בכל העמודות (שם, גודל וכו') ?</p>
<p dir="rtl">מה שעושים ב XAML עשיתי בקוד של הבנאי:<br />
אתה נותן שם לכל עמודה בליסט-ויו</p>
<pre><code>   שם_עמודה.DisplayMemberBinding = New Binding("שם_המאפיין")
</code></pre>
</blockquote>
<p dir="rtl">הבעיה שהקוד שלך לא הכיל בכלל שם לעמודות וגם לא לטבלה כולה לכן התפלאתי.</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב11/11/2013 15:18 (+02:00)</em></p>
]]></description><link>https://tchumim.com/post/1007</link><guid isPermaLink="true">https://tchumim.com/post/1007</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:34:00 GMT]]></title><description><![CDATA[<p dir="rtl">זה ממש נפלא כעת! האיקונים מוסיפים המון.<br />
רק הבעיה שהם לא חדים אע''פ שהם מוצגים ברזולוציה המקורית שלהם, אותו דבר ב WINFORMS היא נראה יותר חד, יש מה לעשות עם זה?</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 21:00 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1006</link><guid isPermaLink="true">https://tchumim.com/post/1006</guid><dc:creator><![CDATA[רחמים]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:34:00 GMT]]></title><description><![CDATA[<p dir="rtl">יפה מאוד, תודה רבה יישר כח!</p>
<p dir="rtl"><a class="plugin-mentions-user plugin-mentions-a" href="/user/%D7%93%D7%95%D7%93" aria-label="Profile: דוד">@<bdi>דוד</bdi></a> ל.ט.</p>
<blockquote>
<p dir="rtl">מעניין אותי איך הצלחת להכניס ערכים טקסטואליים בכל העמודות (שם, גודל וכו') ?</p>
</blockquote>
<p dir="rtl">מה שעושים ב XAML עשיתי בקוד של הבנאי:<br />
אתה נותן שם לכל עמודה בליסט-ויו</p>
<pre><code>   שם_עמודה.DisplayMemberBinding = New Binding("שם_המאפיין")
</code></pre>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 20:34 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1005</link><guid isPermaLink="true">https://tchumim.com/post/1005</guid><dc:creator><![CDATA[רחמים]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:34:00 GMT]]></title><description><![CDATA[<p dir="rtl">אגב, אח"כ ערכת את הודעתך ושמת שם את הXAML.<br />
ואחרי עיון בקוד שלך, ומזה שהשאלה שלך נסובה רק על האייקון,<br />
מעניין אותי איך הצלחת להכניס ערכים טקסטואליים בכל העמודות (שם, גודל וכו') ?</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 20:04 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1004</link><guid isPermaLink="true">https://tchumim.com/post/1004</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:34:00 GMT]]></title><description><![CDATA[<p dir="rtl">תחליף את תחילת הקוד, מההצהרה על הDictionary כולל, ועד סוף הפונקציה הראשונה,<br />
בקוד דלהלן:</p>
<pre><code>Public Shared ICO_DIC As New Dictionary(Of String, ImageSource)

'This function get the icon for the specified file path extension
Public Shared Function GetIcon(ByVal filePath As String) As ImageSource
    Try
        Dim wpfBitmap As ImageSource

        'Get the extension
        Dim ext As String = IO.Path.GetExtension(filePath)
        ' בודק אם האיקון כבר קיים 
        ICO_DIC.TryGetValue(ext, wpfBitmap)
        If wpfBitmap IsNot Nothing Then
            Return wpfBitmap
        End If
        Dim shellFileInfo As New SYS_ICO.SHFILEINFO()

        SYS_ICO.SHGetFileInfo(ext, 128, shellFileInfo, _
                    Convert.ToUInt32(Marshal.SizeOf(shellFileInfo)), _
                    Convert.ToUInt32(256I Or 1I Or 16I))

        Dim ico As System.Drawing.Icon = System.Drawing.Icon.FromHandle(shellFileInfo.hIcon)

        wpfBitmap = FromIconToImageSource(ico)
        ICO_DIC.Add(ext, wpfBitmap)
        Return wpfBitmap
    Catch ex As Exception
        Return FromIconToImageSource(My.Resources.איקון)
    End Try

End Function

Private Shared Function FromIconToImageSource(icon As System.Drawing.Icon) As ImageSource
    Dim bitmap As System.Drawing.Bitmap = icon.ToBitmap()
    Dim hBitmap As IntPtr = bitmap.GetHbitmap()

    Dim wpfBitmap As ImageSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                                    hBitmap,
                                    IntPtr.Zero,
                                    Int32Rect.Empty,
                                    BitmapSizeOptions.FromEmptyOptions())
    Return wpfBitmap
End Function
</code></pre>
<p dir="rtl">ואח"כ אתה שם את התוצאה במאפיין הImageSource של המחלקה דלעיל.</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 19:47 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1003</link><guid isPermaLink="true">https://tchumim.com/post/1003</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:59 GMT]]></title><description><![CDATA[<p dir="rtl">אני משתמש בקוד הבא כדי לקבל איקונים:</p>
<pre><code>Imports System.Runtime.InteropServices

Public Class SYS_ICO

    Public Shared ICO_DIC As New Dictionary(Of String, Icon)

     'This function get the icon for the specified file path extension
    Public Shared Function GetIcon(ByVal filePath As String) As System.Drawing.Icon
        Try

            Dim ico As System.Drawing.Icon
            'Get the extension
            Dim ext As String = IO.Path.GetExtension(filePath)
            ' בודק אם האיקון כבר קיים 
            ICO_DIC.TryGetValue(ext, ico)
            If ico IsNot Nothing Then
                Return ico
            End If
            Dim shellFileInfo As New SYS_ICO.SHFILEINFO()

            SYS_ICO.SHGetFileInfo(ext, 128, shellFileInfo, _
                        Convert.ToUInt32(Marshal.SizeOf(shellFileInfo)), _
                        Convert.ToUInt32(256I Or 1I Or 16I))

            ico = System.Drawing.Icon.FromHandle(shellFileInfo.hIcon)
            ICO_DIC.Add(ext, ico)
            Return ico
        Catch ex As Exception
            Return My.Resources.איקון
        End Try

    End Function

    &lt;StructLayout(LayoutKind.Sequential)&gt; _
    Private Structure SHFILEINFO

        Public hIcon As IntPtr
        Public iIcon As Integer
        Public dwAttributes As System.UInt32
        &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)&gt; _
        Public szDisplayName As String
        &lt;MarshalAs(UnmanagedType.ByValTStr, SizeConst:=80)&gt; _
        Public szTypeName As String

    End Structure


    &lt;DllImport("Shell32.dll", ENTRYPOINT:="SHGetFileInfo")&gt; _
    Private Shared Function SHGetFileInfo(
        ByVal pszPath As String,
        ByVal dwFileAttributes As System.UInt32,
        ByRef psfi As SHFILEINFO,
        ByVal cbFileInfo As System.UInt32,
        ByVal uFlags As System.UInt32) As IntPtr
    End Function

End Class
</code></pre>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 17:55 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1002</link><guid isPermaLink="true">https://tchumim.com/post/1002</guid><dc:creator><![CDATA[רחמים]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:59 GMT]]></title><description><![CDATA[<p dir="rtl">ציפיתי שתיקח את מה ששלחתי הלאה, לא חשבתי שגמרתי.<br />
אתה צודק, טעיתי בכך שבחרתי את השם Image בקוד, אחרי שבXAML הפניתי לicon. צריך לשנות את אחד מהם כדי ששניהם יהיו אותו השם.</p>
<p dir="rtl">כדי להציג את האייקון שלך, אני צריך לדעת איך אתה מחזיק אותו. כאייקון?</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 16:47 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1001</link><guid isPermaLink="true">https://tchumim.com/post/1001</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:59 GMT]]></title><description><![CDATA[<p dir="rtl">תודה רבה,<br />
כל זה הבנתי, אבל איפה האייקון?</p>
<p dir="rtl">בקוד שלך הבאת:</p>
<pre><code>&lt;GridViewColumn.CellTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;Image Source="{Binding icon}" /&gt;
                    &lt;/DataTemplate&gt;
                &lt;/GridViewColumn.CellTemplate&gt;
</code></pre>
<p dir="rtl">ואני עשיתי בקוד שלי אותו דבר:</p>
<pre><code>&lt;GridViewColumn Header="ico"  Width="30" DisplayMemberBinding="{Binding ICON}"   CellTemplate="{Binding ICON}" /&gt;
</code></pre>
<p dir="rtl">אבל האיקון לא מופיע כי לא שמנו כלום ב Public Property Image As ImageSource<br />
בקיצור איך אני מגדיר את המאפיין הזה בזמן ריצה ?<br />
ושוב תודה רבה.</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 14:45 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/1000</link><guid isPermaLink="true">https://tchumim.com/post/1000</guid><dc:creator><![CDATA[רחמים]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:59 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:58 GMT]]></title><description><![CDATA[<p dir="rtl">למה לא להביא xaml?<br />
חשוב לדעת איפה אתה אוחז.<br />
א. יש הרבה הרבה אפשרויות להציג מידע בפקדי xaml.<br />
ב. יש הרבה אפשרויות איך לנהל את הקוד מאחורה.<br />
ג. לליסטויו יש אפשרויות תצוגה טבלאית ואחרות.</p>
<p dir="rtl">עשיתי דוגמה בסיסית עם פירוט רב כדי שתראה את היקף ההיבטים.<br />
קודם הXAML:</p>
<pre><code>&lt;ListView  ItemsSource="{Binding Source={StaticResource CollForList}}" MouseDoubleClick="listFiles_MouseDoubleClick" &gt;
    &lt;ListView.View&gt;
        &lt;GridView&gt;
            &lt;GridViewColumn &gt;
                &lt;GridViewColumn.CellTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;Image Source="{Binding icon}" /&gt;
                    &lt;/DataTemplate&gt;
                &lt;/GridViewColumn.CellTemplate&gt;
            &lt;/GridViewColumn&gt;
            &lt;GridViewColumn Header="שם" DisplayMemberBinding="{Binding Name}" /&gt;
            &lt;GridViewColumn Header="תאריך שינוי" DisplayMemberBinding="{Binding DateChange}" /&gt;
        &lt;/GridView&gt;
    &lt;/ListView.View&gt;
&lt;/ListView&gt;
</code></pre>
<p dir="rtl">הזאמל הזה עושה שימוש בריסורס, אביא אף אותו</p>
<pre><code>&lt;Window.Resources&gt;
    &lt;CollectionViewSource x:Key="CollForList" /&gt;
&lt;/Window.Resources&gt;
</code></pre>
<p dir="rtl">הקוד VB במקרה זה:</p>
<pre><code>Private Coll As CollectionViewSource
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
    Coll = Me.Resources("CollForList")
    ListBuilder(New IO.DirectoryInfo("c:\"))
End Sub

Private Sub ListBuilder(dirBase As IO.DirectoryInfo)
    Dim files = From file In dirBase.EnumerateFiles()
                Select New FileOrFolder(file)

    Dim directories = From dir In dirBase.EnumerateDirectories
                      Select New FileOrFolder(dir)

    Coll.Source = files.Concat(directories)
End Sub

Private Sub listFiles_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs)
    Dim f = TryCast(CType(e.OriginalSource, FrameworkElement).DataContext, FileOrFolder)
    If f IsNot Nothing Then
        If f.IsDir Then
            ListBuilder(New IO.DirectoryInfo(f.FullName))
        End If
    End If
End Sub
</code></pre>
<p dir="rtl">הקוד משתמש במחלקה זאת:</p>
<pre><code>Class FileOrFolder
    Public FullName As String
    Public Property IsDir As Boolean
    Public Property Name As String
    Public Property DateChange As Date
    Public Property Image As ImageSource

    Public Sub New(file As IO.FileInfo)
        FullName = file.FullName
        Name = file.Name
        '....
    End Sub
    Public Sub New(dir As IO.DirectoryInfo)
        IsDir = True
        FullName = dir.FullName
        Name = dir.Name
        '....
    End Sub
End Class
</code></pre>
<p dir="rtl">תשלים את הקוד החסר (איפה שיש שלוש נקודות)  לפי טעמך.<br />
יש כאן הרבה "הנחות עבודה". כל דבר שעשיתי אפשר אחרת.<br />
אבל זה מבט מהיר לאיך שWPF מתמודד עם נתונים.</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 13:05 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/999</link><guid isPermaLink="true">https://tchumim.com/post/999</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:58 GMT]]></title><description><![CDATA[<p dir="rtl">החלון שאני עוסק בו כעת אמור להציג תוכן תיקיה נבחרת, התוכן כולל קבצים ותקיות משנה, ואני רוצה להציג אותו ב ListView,<br />
עמודה הראשונה ב ListView תהיה האיקון של הקובץ או התקיה כפי שהוא מוגדר בריגיסטרי [ולזה יש לי קוד שמחלץ את האייקונים] ובשאר העמודות ב ListView אני מציג טקסט כמו שם הקובץ תאריך שינוי וכדומה.</p>
<p dir="rtl">התיקיה שאותה אני רוצה להראות בתוך ה ListView משתנת כל פעם ע''י משתמש ולכן גם האיקונים צריכים להשתנות בהתאם.</p>
<p dir="rtl">תודה רבה.</p>
<pre><code>&lt;Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="765"&gt;
    &lt;Grid&gt;
        &lt;ListView Margin="12,41,12,12"  ItemsSource="{Binding}"
           GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
                  SelectionMode="Multiple" Foreground="Black"&gt;

            &lt;ListView.View&gt;
                &lt;GridView&gt;
                    &lt;GridViewColumn Header="ico"  Width="30" DisplayMemberBinding="{Binding ICON}"   CellTemplate="{Binding ICON}" /&gt;
                    &lt;GridViewColumn Header="שם" Width="200"   /&gt;
                    &lt;GridViewColumn  Header="תיקיה מכילה" Width="200"  /&gt;
                    &lt;GridViewColumn Header="סוג"  Width="70"  /&gt;
                    &lt;GridViewColumn Header="תאריך שינוי"  Width="200"  /&gt;
                    &lt;GridViewColumn Header="גודל"  Width="100"   /&gt;
                &lt;/GridView&gt;

            &lt;/ListView.View&gt;
        &lt;/ListView&gt;
    &lt;/Grid&gt;
&lt;/Window&gt;
</code></pre>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 11:05 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/998</link><guid isPermaLink="true">https://tchumim.com/post/998</guid><dc:creator><![CDATA[רחמים]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:58 GMT</pubDate></item><item><title><![CDATA[Reply to WPF - ListView on Mon, 29 Jan 2018 10:33:58 GMT]]></title><description><![CDATA[<p dir="rtl">אם אתה יודע איך משנים בזמן ציור, מסתבר ששמת בתוך הListView פקד Image.<br />
מסתבר ששמת את זה בטמפלט, אבל אני מנחש מידי הרבה.<br />
תעלה קוד זאמל רלוונטי לעניין. ואם זה לא סוד צבאי, כדאי גם שתרחיב על המטרות,<br />
כי אתה יכול לקבל "תשועה ברוב יועץ" איזה דרך לבחור מבין עשרות אפשרויות.</p>
<p dir="rtl"><em>פורסם במקור בפורום CODE613 ב17/10/2013 10:57 (+03:00)</em></p>
]]></description><link>https://tchumim.com/post/997</link><guid isPermaLink="true">https://tchumim.com/post/997</guid><dc:creator><![CDATA[dovid]]></dc:creator><pubDate>Mon, 29 Jan 2018 10:33:58 GMT</pubDate></item></channel></rss>