Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf ListBoxItem边框有时隐藏在ListBox';滚动条_Wpf_Listbox_Listboxitem - Fatal编程技术网

Wpf ListBoxItem边框有时隐藏在ListBox';滚动条

Wpf ListBoxItem边框有时隐藏在ListBox';滚动条,wpf,listbox,listboxitem,Wpf,Listbox,Listboxitem,大多数情况下,列表框的显示方式如下: <ScrollViewer> <ListBox> <!--strip default presenter--> <ItemsControl.Template> <ControlTemplate> <ItemsPresenter /> </ControlTemplate> </ItemsControl

大多数情况下,列表框的显示方式如下:

<ScrollViewer>

  <ListBox>

    <!--strip default presenter-->
    <ItemsControl.Template>
      <ControlTemplate>
        <ItemsPresenter />
      </ControlTemplate>
    </ItemsControl.Template>

    <ListBox.ItemTemplate>
      <DataTemplate>
        <!--data template goes here-->
      </DataTemplate>
    </ListBox.ItemTemplate>

  </ListBox>

</ScrollViewer>

但偶尔它看起来是这样的:

<ScrollViewer>

  <ListBox>

    <!--strip default presenter-->
    <ItemsControl.Template>
      <ControlTemplate>
        <ItemsPresenter />
      </ControlTemplate>
    </ItemsControl.Template>

    <ListBox.ItemTemplate>
      <DataTemplate>
        <!--data template goes here-->
      </DataTemplate>
    </ListBox.ItemTemplate>

  </ListBox>

</ScrollViewer>

知道出了什么问题吗

--编辑--


我从问题中删除了控件模板,因为当我从程序中删除它们时,问题仍然存在。这是WPF错误吗?

您是否尝试过在列表框项目边框上设置SnapsToDevicePixels=“True”?由于厚度为1“设备独立单位”,我认为边界位于像素边界上。

您是否尝试过在列表框项目边界上设置SnapsToDevicePixels=“True”?由于厚度为1“设备独立单位”,我认为边界落在像素边界上。

我遇到了几乎完全相同的问题,请看,我从未找到真正的答案。我现在做的是从listbox模板中剥离scrollviewer,并将整个listbox本身嵌入到一个新的scrollviewer中。虽然不适用于所有场合,但这是一个巧妙的技巧

xaml如下所示:

<ScrollViewer>

  <ListBox>

    <!--strip default presenter-->
    <ItemsControl.Template>
      <ControlTemplate>
        <ItemsPresenter />
      </ControlTemplate>
    </ItemsControl.Template>

    <ListBox.ItemTemplate>
      <DataTemplate>
        <!--data template goes here-->
      </DataTemplate>
    </ListBox.ItemTemplate>

  </ListBox>

</ScrollViewer>


我不是一个庞大的xaml向导,所以如果有人能将它转换成一段可重用的代码,请务必这样做。

我遇到了几乎完全相同的问题,请看,我从未找到真正的答案。我现在做的是从listbox模板中剥离scrollviewer,并将整个listbox本身嵌入到一个新的scrollviewer中。虽然不适用于所有场合,但这是一个巧妙的技巧

xaml如下所示:

<ScrollViewer>

  <ListBox>

    <!--strip default presenter-->
    <ItemsControl.Template>
      <ControlTemplate>
        <ItemsPresenter />
      </ControlTemplate>
    </ItemsControl.Template>

    <ListBox.ItemTemplate>
      <DataTemplate>
        <!--data template goes here-->
      </DataTemplate>
    </ListBox.ItemTemplate>

  </ListBox>

</ScrollViewer>


我不是一个庞大的xaml向导,所以如果有人能将其转换为可重用的代码,请务必这样做。

你能发布相关代码吗?你能发布相关代码吗?