2012-03-16 9 views
4

Windows版のJavaアプリケーションでWPFを使用します。私はそれがSWTでそれを行うことは簡単であり、SWT要素(please see this)のwpf ResourceDictionary XAMLもサポートしていることがわかりました。 SWT WPFの実装はうまくいきましたが、私はWPF themeをどのように置くことができるのか分かりませんでした。 SWTウィジェットのいくつかは同じorg.eclipse.swt.widgets.ButtonsetDataメソッドを持っていますが、そのうちのいくつかはorg.eclipse.swt.widgets.Displayのようにそのメソッドを持っていません。 shellsetDateメソッドは、ウィンドウ全体にテーマを設定しません。SWT WPFプログラムのテーマはどのように設定できますか?

SWT WPFプログラムのウィンドウ全体にテーマを設定するにはどうすればよいですか?ここで

はサンプルコードです:

import org.eclipse.swt.widgets.Button; 
import org.eclipse.swt.widgets.Display; 
import org.eclipse.swt.widgets.Shell; 
import org.eclipse.swt.widgets.Menu; 
import org.eclipse.swt.SWT; 
import org.eclipse.swt.widgets.MenuItem; 

public class MainForm { 

    protected Shell shell; 

    public static void main(String[] args) { 
     try { 
      MainForm window = new MainForm(); 
      window.open(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 

    public void open() { 
     Display display = Display.getDefault(); 
     createContents(); 
     shell.open(); 
     shell.layout(); 
     while (!shell.isDisposed()) { 
      if (!display.readAndDispatch()) { 
       display.sleep(); 
      } 
     } 
    } 

    protected void createContents() { 
     shell = new Shell(); 
     shell.setData(
       "ResourceDictionary", 
       "ExpressionDark.xaml"); 
     // theme not applied on entire window, just buttons 

     shell.setSize(450, 300); 
     shell.setText("Window Title"); 

     Button button = new Button(shell, SWT.FLAT); 
     button.setText("Button"); 
     button.setSize(250, 50); 
     button.setBounds(0, 50, 250, 50); 

     Menu menu = new Menu(shell, SWT.BAR); 
     shell.setMenuBar(menu); 

     MenuItem mntmNewSubmenu = new MenuItem(menu, SWT.CASCADE); 
     mntmNewSubmenu.setText("New SubMenu"); 

     Menu menu_1 = new Menu(mntmNewSubmenu); 
     mntmNewSubmenu.setMenu(menu_1); 

    } 
} 

答えて

0

私はSWT WPFを使用していない認めなければならないので、これは全く動作しない場合がありますが、これはあなたが標準WPF

を使用していた場合は、一般的に何をするのかでありますあなたはだから私はprovidin推測この

<!-- Custom Window : to allow repositioning of ResizeGrip--> 
<ControlTemplate x:Key="WindowTemplateKey" TargetType="{x:Type Window}"> 
    <Border Background="{TemplateBinding Background}" 
      BorderBrush="{TemplateBinding BorderBrush}" 
      BorderThickness="{TemplateBinding BorderThickness}"> 
     <Grid> 
      <AdornerDecorator> 
       <ContentPresenter/> 
      </AdornerDecorator> 
      <ResizeGrip Visibility="Collapsed" 
         HorizontalAlignment="Right" x:Name="WindowResizeGrip" 
         Style="{DynamicResource ResizeGripStyle1}" 
         VerticalAlignment="Bottom" IsTabStop="false"/> 
     </Grid> 
    </Border> 
    <ControlTemplate.Triggers> 
     <MultiTrigger> 
      <MultiTrigger.Conditions> 
       <Condition Property="ResizeMode" Value="CanResizeWithGrip"/> 
       <Condition Property="WindowState" Value="Normal"/> 
      </MultiTrigger.Conditions> 
      <Setter Property="Visibility" 
       TargetName="WindowResizeGrip" Value="Visible"/> 
     </MultiTrigger> 
    </ControlTemplate.Triggers> 
</ControlTemplate> 

のようなテンプレートに何かを持っているでしょう

<Window 
    .... 
    .... 
    .... 
    ResizeMode="CanResizeWithGrip" 
    Template="{StaticResource WindowTemplateKey}"> 
</Window> 

あなたはウィンドウを持っていたグラム(シェル、あなたのケースで「CustomShellTemplateFile.xaml」と呼ばれる別のResourceDictionary(XAMLファイル)と言うに指定された)あなたはshell.setData( 「のResourceDictionary」、 「CustomShellTemplateFile.xaml

ような何かを行うことができます");

+0

申し訳ありませんが、動作しませんでした:( –

関連する問題