C# Prism框架登录窗口跳转到主窗口后 ToggleButton 无法找到绑定元素的问题,
直接跳转到主窗口正常
<hc:GlowWindow xmlns:Views="clr-namespace:WPFjjhfuzhu41.Views"
x:Class="WPFjjhfuzhu41.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation%22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml%22
xmlns:prism="http://prismlibrary.com/%22
xmlns:hc="https://handyorg.github.io/handycontrol%22
ResizeMode="CanResizeWithGrip"
Style="{StaticResource WindowGlow}"
ActiveGlowColor="{DynamicResource PrimaryColor}"
Background="{DynamicResource MainContentBackgroundBrush}"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors%22
xmlns:ext="clr-namespace:WPFjjhfuzhu41.Extensions"
Height="768"
Width="1280">
<hc:GlowWindow.NonClientAreaContent>
<StackPanel Orientation="Horizontal">
<ToggleButton Panel.ZIndex="1"
Margin="-10 0 0 0"
Style="{StaticResource ToggleButtonIcon}"
Background="DarkViolet"
hc:IconSwitchElement.Geometry="{StaticResource RightGeometry}"
hc:IconSwitchElement.GeometrySelected="{StaticResource LeftGeometry}"
IsChecked="{Binding IsOpen ,ElementName=DrawerLeft}"/>
<TextBlock Text="{Binding Title}"
FontSize="14"
VerticalAlignment="Center"></TextBlock>
</StackPanel>
</hc:GlowWindow.NonClientAreaContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<hc:Drawer Name="DrawerLeft"
Dock="Left"
ShowMode="Push">
<Border Background="{DynamicResource RegionBrush}"
Width="300"
BorderThickness="0,1,0,0"
BorderBrush="{DynamicResource BorderBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<hc:SideMenu Name="sideMenu"
Grid.Row="1">
<hc:SideMenuItem Header="配置"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding Header,RelativeSource={RelativeSource Self}}">
<hc:SideMenuItem.Icon>
<TextBlock Text=""
Style="{StaticResource TextBlockSubTitle}" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem Header="关于"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding Header,RelativeSource={RelativeSource Self}}">
<hc:SideMenuItem.Icon>
<TextBlock Text=""
Style="{StaticResource TextBlockSubTitle}" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenu>
</Grid>
</Border>
</hc:Drawer>
<ContentControl Grid.Row="0"
prism:RegionManager.RegionName="{x:Static ext:PrismManager.MainViewRegionName}" />
<StackPanel Grid.Row="1"
Orientation="Horizontal"
VerticalAlignment="Center"
Margin="10 0 0 0">
<StackPanel Orientation="Horizontal"
Width="150"
Margin="0 0 20 0">
<TextBlock Text="总金币:" />
<TextBlock Text="{Binding TotalCoin,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal"
Width="150"
Margin="0 0 20 0">
<TextBlock Text="最低金币:" />
<TextBlock Text="{Binding HighCoin,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal"
Width="150"
Margin="0 0 20 0">
<TextBlock Text="最低金币:" />
<TextBlock Text="{Binding LowCoin,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"></TextBlock>
</StackPanel>
</StackPanel>
</Grid>
运行结果及详细报错内容
错误 1 null IsOpen ToggleButton.IsChecked Nullable`1 找不到源: ElementName=DrawerLeft。 \views\mainwindow.xaml 22
我想要达到的结果,如果你需要快速回答,请尝试 “付费悬赏”
付费悬赏