在 WizardPage-WPF 的 CanSelectNextPage 上多重绑定时出现语法问题
Syntax issue while multibinding on CanSelectNextPage of WizardPage-WPF
我想在名为 CanSelectNextPage 的 WizardPage 属性 上使用多重绑定。
WizardPage 连接到扩展的 WPF 工具包包。
我做到了:
在 MainWindow.xaml:
<xctk:WizardPage x:Name="Page1" PageType="Interior"
Title="DB Configuration-Stage 1"
Description="Select between create new GFACT environment to update existing gfact database"
Background="#FF27E0E0" BorderBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Leave="Page1_Leave">
<WizardPage.CanSelectNextPage>
<MultiBinding Converter="{StaticResource CanSelectNextPage1}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="outputFolder" Path="Text" Mode="OneWay"/>
<Binding ElementName ="reducedModelFolder" Path="Text" Mode="OneWay"/>
</MultiBinding>
</WizardPage.CanSelectNextPage>
<Grid Margin="-5 -10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<RadioButton x:Name="RadioButNew" Content="New" Margin="5 10" FontSize="13.333"/>
<RadioButton x:Name="RadioButUpdate" Content="Update" Margin="5 10" Grid.Column="2" FontSize="13.333"/>
<Label x:Name="outputFolderLabel" Content="Select destination folder:" Height="30" Grid.Row="1" Grid.Column="0" FontSize="13.333" Margin="5 10">
<Label.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Label.Visibility>
</Label>
<Label x:Name="reducedFolderLabel" Content="Select reduced model folder:" Height="30" Grid.Row="2" Grid.Column="0" FontSize="13.333" Margin="5 10 ">
<Label.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Label.Visibility>
</Label>
<TextBox x:Name="outputFolder" Width ="200" Height="30" Grid.Row="1" Grid.Column="1" Margin="5 10">
<TextBox.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</TextBox.Visibility>
</TextBox>
<TextBox x:Name="reducedModelFolder" Width ="200" Height="30" Grid.Row="2" Grid.Column="1" Margin="5 10">
<TextBox.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</TextBox.Visibility>
</TextBox>
<Button x:Name="outputFolderOpenBut" Content="" Grid.Row="1" Grid.Column="2" Width="30" Height="30" VerticalAlignment="Top" Margin="5 10" >
<Button.Background>
<ImageBrush ImageSource="OpenPL.bmp" />
</Button.Background>
<Button.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Button.Visibility>
</Button>
<Button x:Name="reducedModelFolderOpenBut" Content="" Grid.Row="2" Grid.Column="2" Width="30" Height="30" VerticalAlignment="Top" Margin="5 10" >
<Button.Background>
<ImageBrush ImageSource="OpenPL.bmp" Stretch="Uniform"/>
</Button.Background>
<Button.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Button.Visibility>
</Button>
</Grid>
</xctk:WizardPage>
在 MainWindow.xaml.cs:
public class CanSelectNextPage1 : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values[0] is bool && values[1] is bool && values[2] is string && values[3] is string)
if (((bool)values[0] || (bool)values[1]) && (values[2] != null) && (values[3] != null))
{
return true;
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
错误 "Wizard Page is not supported in WPF" 出现在:
<WizardPage.CanSelectNextPage>
我认为这是语法问题 - 有人可以帮助我吗?我是 WPF 新手..
应该是
<xctk:WizardPage.CanSelectNextPage>
<MultiBinding Converter="{StaticResource CanSelectNextPage1}">
<Binding ElementName="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName="outputFolder" Path="Text" Mode="OneWay"/>
<Binding ElementName="reducedModelFolder" Path="Text" Mode="OneWay"/>
</MultiBinding>
</xctk:WizardPage.CanSelectNextPage>
我想在名为 CanSelectNextPage 的 WizardPage 属性 上使用多重绑定。
WizardPage 连接到扩展的 WPF 工具包包。
我做到了:
在 MainWindow.xaml:
<xctk:WizardPage x:Name="Page1" PageType="Interior"
Title="DB Configuration-Stage 1"
Description="Select between create new GFACT environment to update existing gfact database"
Background="#FF27E0E0" BorderBrush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"
Leave="Page1_Leave">
<WizardPage.CanSelectNextPage>
<MultiBinding Converter="{StaticResource CanSelectNextPage1}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="outputFolder" Path="Text" Mode="OneWay"/>
<Binding ElementName ="reducedModelFolder" Path="Text" Mode="OneWay"/>
</MultiBinding>
</WizardPage.CanSelectNextPage>
<Grid Margin="-5 -10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<RadioButton x:Name="RadioButNew" Content="New" Margin="5 10" FontSize="13.333"/>
<RadioButton x:Name="RadioButUpdate" Content="Update" Margin="5 10" Grid.Column="2" FontSize="13.333"/>
<Label x:Name="outputFolderLabel" Content="Select destination folder:" Height="30" Grid.Row="1" Grid.Column="0" FontSize="13.333" Margin="5 10">
<Label.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Label.Visibility>
</Label>
<Label x:Name="reducedFolderLabel" Content="Select reduced model folder:" Height="30" Grid.Row="2" Grid.Column="0" FontSize="13.333" Margin="5 10 ">
<Label.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Label.Visibility>
</Label>
<TextBox x:Name="outputFolder" Width ="200" Height="30" Grid.Row="1" Grid.Column="1" Margin="5 10">
<TextBox.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</TextBox.Visibility>
</TextBox>
<TextBox x:Name="reducedModelFolder" Width ="200" Height="30" Grid.Row="2" Grid.Column="1" Margin="5 10">
<TextBox.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</TextBox.Visibility>
</TextBox>
<Button x:Name="outputFolderOpenBut" Content="" Grid.Row="1" Grid.Column="2" Width="30" Height="30" VerticalAlignment="Top" Margin="5 10" >
<Button.Background>
<ImageBrush ImageSource="OpenPL.bmp" />
</Button.Background>
<Button.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Button.Visibility>
</Button>
<Button x:Name="reducedModelFolderOpenBut" Content="" Grid.Row="2" Grid.Column="2" Width="30" Height="30" VerticalAlignment="Top" Margin="5 10" >
<Button.Background>
<ImageBrush ImageSource="OpenPL.bmp" Stretch="Uniform"/>
</Button.Background>
<Button.Visibility>
<MultiBinding Converter="{StaticResource FilterConverter}">
<Binding ElementName ="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName ="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
</MultiBinding>
</Button.Visibility>
</Button>
</Grid>
</xctk:WizardPage>
在 MainWindow.xaml.cs:
public class CanSelectNextPage1 : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values[0] is bool && values[1] is bool && values[2] is string && values[3] is string)
if (((bool)values[0] || (bool)values[1]) && (values[2] != null) && (values[3] != null))
{
return true;
}
return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
错误 "Wizard Page is not supported in WPF" 出现在:
<WizardPage.CanSelectNextPage>
我认为这是语法问题 - 有人可以帮助我吗?我是 WPF 新手..
应该是
<xctk:WizardPage.CanSelectNextPage>
<MultiBinding Converter="{StaticResource CanSelectNextPage1}">
<Binding ElementName="RadioButNew" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName="RadioButUpdate" Path="IsChecked" Mode="OneWay"/>
<Binding ElementName="outputFolder" Path="Text" Mode="OneWay"/>
<Binding ElementName="reducedModelFolder" Path="Text" Mode="OneWay"/>
</MultiBinding>
</xctk:WizardPage.CanSelectNextPage>