此问题在此处已有答案:
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工程
1条答案
按热度按时间7tofc5zh1#
在
App.xaml
文件中将x:Name
更改为x:Key
:字符串