小编vor*_*olf的帖子

为什么回收不起作用?

我们有一个桌面应用程序,我们有一个ListView,它ListView.ItemTemplate是一个扩展的KPageScrollViewerScrollViewer

虽然我们设定VirtualizingStackPanel.IsVirtualizing="True"VirtualizingStackPanel.VirtualizationMode="Recycling"

我们注意到KPageScrollViewer的构造函数(在其中ItemTemplate)总是在查看ListView中的项目时执行.

我们期望它将被创建4到5次,然后,相同的实例将用于查看数据,因为我们使用的是回收模式,但这不会发生,因此我们最终会得到越来越多的KPageScrollViewer实例创造..

是因为我们定制了ListView.ItemsPanel吗?

<ListView.ItemsPanel>
    <ItemsPanelTemplate >
        <p:KVirtualizingStackPanel IsItemsHost="True"
Run Code Online (Sandbox Code Playgroud)

有什么好主意吗?我想知道哪些原因会导致回收功能丢失?

<ListView  x:Class="KETAB.KStudio.Stage.PagesView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="clr-namespace:KETAB.KStudio.Stage"
    Name="PagesList" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" 
    Loaded="instScroll_Loaded"
    AllowDrop="True" 
    MouseMove="PagesList_MouseMove"
    ScrollViewer.PanningMode="None"
    VirtualizingStackPanel.IsVirtualizing="True"
    VirtualizingStackPanel.CleanUpVirtualizedItem="PagesList_CleanUpVirtualizedItem"
    VirtualizingStackPanel.VirtualizationMode="Recycling"
    >

    <ListView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="Resources/StageResources.xaml"/>
                <ResourceDictionary Source="/KETAB.KStudio.UserControls;component/ScrollViewerStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <SolidColorBrush  x:Key="{x:Static SystemColors.HighlightBrushKey}" Opacity="0.4" Color="Transparent" />
            <SolidColorBrush  x:Key="{x:Static SystemColors.ControlBrushKey}"  Opacity="0.4" Color="Transparent"  />
            <!--<p:PageWidthConverter x:Key="PageWidthConverter" />-->
            <p:PageWidthConverter x:Key="pageWidthConverter" />
            <p:PageHeightConverter x:Key="pageHeightConverter" />
            <Style  TargetType="{x:Type ListViewItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding …
Run Code Online (Sandbox Code Playgroud)

.net wpf scroll recycle

6
推荐指数
1
解决办法
658
查看次数

隐藏控件时隐藏验证装饰

在WPF中,如何在隐藏控件时隐藏验证错误模板装饰(默认情况下为红色框)?当我隐藏我的控件(以便于在视图之间切换)时,错误装饰会一直存在.

更难的是,我如何使用MVVM做到这一点?

wpf adorner mvvm

4
推荐指数
1
解决办法
3644
查看次数

C#WPF Datagrid:从SelectionChanged事件中获取值

这一直让我疯狂.我只想在数据网格中选择行的值,它在VB.net中工作,我对c#有点新,我无法让它工作.

在VB中我的工作代码是:

Private Sub dg_qc_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs)

        Dim TempListItem As QCProperties = CType(sender, DataGrid).SelectedItem

        Dim temp1 As String = TempListItem.PartNumber

End Sub
Run Code Online (Sandbox Code Playgroud)

在C#我有:

    private void dg_blockList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
    {
        dgProperties tempItems = ((DataGrid)sender).SelectedItem;

        string tempModel = tempItems.modelRev;
        string tempDate = tempItems.date;
    }
Run Code Online (Sandbox Code Playgroud)

我收到错误"无法将类型'对象'隐式转换为"我的属性类"(你错过了一个演员?)

我在互联网上搜索过,但我没有运气,我知道这是一个简单的修复方法.请帮忙.

谢谢,切尔西

c# wpf datagrid

3
推荐指数
1
解决办法
1万
查看次数

Silverlight 4:图表工具包颜色集

我将我的Chart代码从visifire迁移到Toolkit.我想知道Visifire to Toolkit的ColorSet属性[样本值Caravan,Picasso ..]的对应部分.

有没有?

TIA

silverlight charts silverlight-toolkit silverlight-4.0

3
推荐指数
1
解决办法
4068
查看次数

添加到文本文件而不删除

我需要在一行中添加4个变量数,但是使用当前代码它只是替换数字,从而使它毫无意义.

using (StreamWriter writer = new StreamWriter("build.txt"))
{
    writer.Write(" " + layer + " " + x + " " + y + " " + block);
    Console.WriteLine("[" + layer + "," + x + "," + y + "," + block + "]");                   
}
Run Code Online (Sandbox Code Playgroud)

所以我需要它写...

 l x y b l x y b l x y b l x y b ...
Run Code Online (Sandbox Code Playgroud)

...但它没有像那样工作,互联网并没有特别有用,希望这里可以提供帮助.

c# text streamwriter

2
推荐指数
2
解决办法
3682
查看次数