2016-02-13 47 views
2

我想在WizardPage的屬性CanSelectNextPage上使用多重綁定。在頁面的CanSelectNextPage上多重綁定時出現語法問題WPF

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(); 
    } 
} 

錯誤 「嚮導頁不支持WPF」 出現在:

<WizardPage.CanSelectNextPage> 

我假設它的語法問題 - 有人可以幫我嗎?我是新手在WPF ..

回答

0

應該

<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>