0

さまざまな条件
でツールチップを動的にバインドする方法 v ソリューションに 2 つのプロジェクトがあります v PRISM フレームワークを使用しています

StudentStatusUserControl.xaml.cs に Telerik RadButton を含める

                 <telerik:RadButton Name="button1" Content="Stauses" Height="24" HorizontalAlignment="Left" VerticalAlignment="Top" Width="112" FontSize="12" Margin="2,2,2,2"
                prism:Click.Command="{Binding ButtonstatusCommand}">

これは特定の条件で有効になり、無効になっている場合は、条件に応じてマウス ホバーまたはツールチップ情報を表示する必要があります

StudentStatusViewModel.cs で

    private bool CanExecuteButtonStatusCommand(object o)
    {
        return SharedLogicBL.CanExecuteButtonStatusCommand(controller,dataService,  _selectedItem);
    }

GeneralBL プロジェクトの SharedLogicBL.cs

      public static bool CanExecuteUnplannedInspection(BaseController controller, DataService dataService, SDataItem selectedItem)
    {
       if(controller.currentuser.Isallowed())
          {
            if(selectedItem!=null)
               {
                 Orders = dataservice.GetOrders(selectedItem);
                  return !Orders.Any();
                }
            }
            else
               return false;
       }

上記のメソッドでは、ユーザーに権限があるかどうかを確認します。そうでない場合は、「ユーザーには権限がありません」というボタンのツールチップがあります。最初の条件が true であるとします。選択された学生には命令がありません」

また、GeneralBL プロジェクトのこの StudentStatusUserControlBL の StudentStatusUserControl.xaml.cs に依存関係プロパティがあります。

4

1 に答える 1

1

Telerik ボタンのツールチップ テキストをデータバインドできるビューモデルにパブリック プロパティを作成します。

public string Button1TooltipText
{
    get { 
         if (!controller.currentuser.Isallowed())
           { return "User doesn't have the rights" }
         else
           { 
             if (!SharedLogicBL.CanExecuteButtonStatusCommand(controller, dataService, _selectedItem))
                 return "the selected student has no orders";
             else
                 return "Execute the unplanned inspection";
           }

         }
}

このプロパティは現在選択されている項目に依存するため、_selectedItem が変更されたときに NotifyPropertyChanged("Button1TooltipText") を呼び出す必要があります。

于 2012-03-07T21:36:47.103 に答える