小编use*_*381的帖子

Screenreader WPF Groupstyles

我试图AutomationProperties.NameGroupStyle控件模板中设置控件的属性,它似乎什么也没产生.我把它设置Expander在我的模板中,但即使我只是放入一些没有绑定的文本,它也没有任何说明.我也试过把一个二传手放在上面GroupItem,但也没用.我有点失落.我希望小组项目上的属性可以解决它.

XAML:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="WpfApplication8.MainWindow"
        x:Name="win"
        Title="MainWindow"
        Width="640"
        Height="480">

  <Grid x:Name="LayoutRoot">
    <ListBox x:Name="lstbx"
             Margin="71,45,99,78"
             ItemsSource="{Binding ElementName=win,
                                       Path=Samples}">
      <ListBox.GroupStyle>
        <GroupStyle>
          <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
              <Setter Property="AutomationProperties.Name"
                      Value="this is a test" />
              <Setter Property="KeyboardNavigation.TabNavigation"
                      Value="Cycle" />
              <Setter Property="Template">
                <Setter.Value>
                  <ControlTemplate TargetType="{x:Type GroupItem}">
                    <Expander Name="templateLstBxExpander"
                              AutomationProperties.Name="test test test"
                              IsExpanded="True">

                      <Expander.Header>
                        <StackPanel Orientation="Horizontal">
                          <Label Name="templateLstBxExpanderHeader"
                                 Content="{Binding Path=Name}"
                                 FontWeight="Bold" />
                        </StackPanel>
                      </Expander.Header>
                      <ItemsPresenter />
                    </Expander>
                  </ControlTemplate>
                </Setter.Value>
              </Setter>
            </Style>
          </GroupStyle.ContainerStyle>
        </GroupStyle>
      </ListBox.GroupStyle>
    </ListBox>
  </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

XAML.cs: …

c# wpf automation screen-readers

37
推荐指数
1
解决办法
945
查看次数

ListViewItem 覆盖默认样式中断网格视图

我想知道是否有人遇到过这种情况。基本上我想要做的是覆盖默认的 listviewitem 来自定义选定的背景/前景。我得到了一切正常和花花公子。问题是,我注意到在我实现网格视图的列表视图上,列被破坏了。我不确定是什么打破了这个。我覆盖默认样式的方法是使用混合通过编辑模板副本来获得完整样式。根据需要对其进行了修改。应用了它。这几乎就是它的样子。有什么想法吗?

<Style TargetType="{x:Type ListViewItem}">
    <Setter Property="Background" Value="Transparent" />
    <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
    <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
    <Setter Property="Padding" Value="2,0,0,0" />
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type ListViewItem}">
        <Border x:Name="Bd"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            BorderThickness="{TemplateBinding BorderThickness}"
            Padding="{TemplateBinding Padding}"
            SnapsToDevicePixels="true">
            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
        </Border>
    <ControlTemplate.Triggers>
        <Trigger Property="IsSelected" Value="true">
            <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource CustomBorderBrush}" />
            <Setter TargetName="Bd" Property="Background" Value="{DynamicResource CustomBackgroundBrush}" />
            <Setter Property="Foreground" Value="{DynamicResource CustomForegroundBrush}" />
        </Trigger>
    <MultiTrigger>
        <MultiTrigger.Conditions> …
Run Code Online (Sandbox Code Playgroud)

c# wpf listview wpf-controls listviewitem

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

方法定义中的operator +有什么作用?

所以我以前从未见过这个,我想弄清楚它的作用:

public static MyFunction operator +(MyObject first, MyObject second)
Run Code Online (Sandbox Code Playgroud)

.net c# operator-overloading

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