小编Chr*_*ian的帖子

Shift + Tab在TreeView控件中不起作用

我无法使用Shift + Tab在包含TextBox的TreeView中工作,使用Tab正向导航工作正常并从TreeBox中的TextBox跳转到TextBox.任何时候使用Shift + Tab时,TreeView中的一个TextBox,然后焦点移动到TreeView外部的前一个控件,而不是TreeView中的前一个控件.

此外,它唯一的Shift + Tab导航无法正常工作,Ctrl + Shift + Tab按预期工作并按正确的顺序工作.

对我做错了什么的建议?

示例代码:

<Window x:Class="TestTabTreeView.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">

<Window.Resources>
    <Style TargetType="TreeViewItem">
        <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue" />
    </Style>
</Window.Resources>

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <TextBox Text="First Line" Grid.Row="0" />

    <TreeView Grid.Row="1" KeyboardNavigation.TabNavigation="Continue" IsTabStop="False">           
        <TreeViewItem IsExpanded="True"><TreeViewItem.Header><TextBox Text="Popular Words"/></TreeViewItem.Header>
            <TreeViewItem><TreeViewItem.Header><TextBox Text="Foo"/></TreeViewItem.Header></TreeViewItem>
            <TreeViewItem><TreeViewItem.Header><TextBox Text="Bar"/></TreeViewItem.Header></TreeViewItem>
            <TreeViewItem><TreeViewItem.Header><TextBox Text="Hello"/></TreeViewItem.Header></TreeViewItem>
        </TreeViewItem>
        <TreeViewItem IsExpanded="True"><TreeViewItem.Header><TextBox Text="Unpopular Words"/></TreeViewItem.Header>
            <TreeViewItem><TreeViewItem.Header><TextBox Text="Work"/></TreeViewItem.Header></TreeViewItem>
            <TreeViewItem><TreeViewItem.Header><TextBox Text="Duplication"/></TreeViewItem.Header></TreeViewItem>
        </TreeViewItem>
    </TreeView>

    <TextBox Text="Last Line" Grid.Row="2" />
</Grid>
Run Code Online (Sandbox Code Playgroud)

c# navigation wpf treeview

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

如何使用TypeConverter转换特定于文化的double?

TypeConverter班上有问题.它适用于CultureInvariant值,但不能转换特定的文化,如英语千位分隔符.下面是一个我无法开展工作的小型测试程序.

这是问题:) - ConvertFromString使用以下消息抛出异常"2,999.95不是Double的有效值." 并且内部异常"输入字符串格式不正确"..

using System;
using System.Globalization;
using System.ComponentModel;

class Program
{
    static void Main()
    {
        try
        {
            var culture = new CultureInfo("en");
            var typeConverter = TypeDescriptor.GetConverter(typeof(double));
            double value = (double)typeConverter.ConvertFromString(
                null, 
                culture, 
                "2,999.95");

            Console.WriteLine("Value: " + value);
        }
        catch (Exception e)
        {
            Console.WriteLine("Error: " + e.Message);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:链接到Connect上的错误报告

.net c# cultureinfo

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

标签 统计

c# ×2

.net ×1

cultureinfo ×1

navigation ×1

treeview ×1

wpf ×1