WPF问题求帮助

daizhiqiang12 2015-11-16 03:48:46
我是WPF初学者,下面有一段代码我不知道怎么处理请大家帮助
<Window.Resources>
<converter:PathToImageConverterLeft x:Key="leftImageConverter"/>
<GeometryGroup x:Key="clipGeometry" FillRule="Nonzero">
<EllipseGeometry RadiusX="90" RadiusY="90" Center="90, 90"></EllipseGeometry>
</GeometryGroup>

<ResourceDictionary>----------提示错误:每个字典条目都必须有一个关联的关键字怎么处理
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources\GlassButton.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/8.gif]
...全文
372 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
meyerxy 2015-11-16
  • 打赏
  • 举报
回复
引用XAML资源,是在APPxaml 中引用,不能直接在<Window.Resources>中引用, 如果需要的话,你直接把Resources\GlassButton.xaml的具体内容复制在<Window.Resources></Window.Resources>中间,并删除那些多余的代码
meyerxy 2015-11-16
  • 打赏
  • 举报
回复
<ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> 剪切到APP.xaml中 ,光标位于<ResourceDictionary />中按F4 选择所需xaml
daizhiqiang12 2015-11-16
  • 打赏
  • 举报
回复
<Window x:Class="QQ.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="600" Width="400" WindowStyle="None" AllowsTransparency="True" MouseLeftButtonDown="MainWindow_MouseLeftButtonDown" xmlns:converter="clr-namespace:QQ.Converters" > <!--<Window.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Resources\GlassButton.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Window.Resources>--> <Window.Resources> <converter:PathToImageConverterLeft x:Key="leftImageConverter"/> <GeometryGroup x:Key="clipGeometry" FillRule="Nonzero"> <EllipseGeometry RadiusX="90" RadiusY="90" Center="90, 90"></EllipseGeometry> </GeometryGroup> </Window.Resources> <Window.Background> <SolidColorBrush /> </Window.Background> <Canvas> <Border CornerRadius="0,30,0,30" Width="400" Height="600" BorderThickness="1" BorderBrush="Black" Canvas.Left="0" Canvas.Top="0" > <Border.Background > <ImageBrush ImageSource="Beijing\I.jpg" /> </Border.Background> <!--<Grid Margin="15" Background="AliceBlue" Opacity="0.7"> </Grid>--> <Border.Effect> <DropShadowEffect BlurRadius="10" Opacity="0.75" /> </Border.Effect> </Border> <Button Width="50" Height="50" Background="#FF660707" Margin="200" Click="closeButtonRectangle_Click" Content="关闭" /> <Grid> <!--<Button Width="50" Height="50" Background="#FF660707" Margin="125" Click="closeButtonRectangle_Click" Content="关闭" />--> <Image Source="{Binding LeftPicture, Converter={StaticResource ResourceKey=leftImageConverter}}" Height="180" HorizontalAlignment="Center" Margin="40" Name="image1" Stretch="Fill" Width="180" Clip="{StaticResource ResourceKey=clipGeometry}"/> <Ellipse HorizontalAlignment="Center" Width="180" Height="180" Stroke="White" VerticalAlignment="Center" StrokeThickness="2" > </Ellipse> </Grid> </Canvas> </Windo> 这是完整的代码我里面有两个Resources(有一个备注但需要用)我不知道怎么把他们结合起来求帮助
  • 打赏
  • 举报
回复 1
<ResourceDictionary Source="Resources\GlassButton.xaml"/> 中 增加一个 x:Key="某个值" 再说,这个ResourceDictionary 应该放到 App.xaml 中的 Application.Resources 节点下的。

111,111

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧