wpf 无法解析资源“x”[重复]

dldeef67  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(158)

此问题在此处已有答案

WPF styles: difference between x:Name and x:Type(2个答案)
What is the Difference Between x:Key, x:Name, and x:UID in a DataTemplate in WPF?(2个答案)
What's the difference between x:Key and x:Name in WPF?(2个答案)
4天前关闭。
主窗口Xaml和我有问题,这一行,但idk为什么resurce存在,但代码找不到

<Grid Width="300" HorizontalAlignment="Left">
                    <TextBlock Margin="20 0" VerticalAlignment="Center" Foreground="#b0b9c6" IsHitTestVisible="False"
                               Panel.ZIndex="1" Text="Ricerca..."
                               Visibility="{Binding ElementName=txtRicerca , Path=Text.IsEmpty,Converter={StaticResource BoolToVis}}"/>

                    <TextBox x:Name="txtSearch" Style="{StaticResource textboxSearch }"/>

                    <Icon:PackIconMaterial Kind="Magnify" Width="15" Height="15" VerticalAlignment="Center"
                                           Margin="0 0 15 0" Foreground="#b0b9c6" HorizontalAlignment="Right"/>

                </Grid>

字符串
App.Xaml

<Style x:Name="textboxSearch" TargetType="TextBox">
            <Setter Property="Background" Value="#ffffff"/>
            <Setter Property="Foreground" Value="#b0b9c6" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Padding" Value="15 10" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="0 10" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBoxBase">
                        <Border x:Name="border" CornerRadius="20" Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
                                BorderThickness="1" BorderBrush="#e0e6ed">
                            <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden"
                                          VerticalScrollBarVisibility="Hidden"/>
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BorderBrush" Value="#d9d9d9" TargetName="border"/>
                            </Trigger>

                            <Trigger Property="IsKeyboardFocused" Value="True">
                                <Setter Property="BorderBrush" Value="#d9d9d9" TargetName="border"/>
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


我试图chenge属性,更改名称,删除,分配到athor文本框,但nothig工程

7tofc5zh

7tofc5zh1#

App.xaml文件中将x:Name更改为x:Key

<Application ...>
    <Application.Resources>
        <Style x:Key="textboxSearch" TargetType="TextBox">
        ...
    </Application.Resources>
</Application>

字符串

相关问题