2011-11-16 6 views
11

मुझे डब्ल्यूडब्ल्यूएफ/एमवीवीएम में रेडियोबुटन्स के साथ थोड़ा परेशान अनुभव के रूप में काम मिल रहा है। डब्ल्यूपीएफ में परेशानियों को दूर करने के लिए "जाने-जाने" का जवाब कैलिबर्न में एक समाधान की तलाश में है। मिक्रो या व्यंजनों में से एक या सहप्रोजेक्ट जैसे उदाहरण कार्यान्वयन। लेकिन मैं radiobutton के लिए एक सम्मेलन का कोई कार्यान्वयन नहीं मिल सकता है। और खुद को बनाने की कोशिश कर रहा हूं मुझे एहसास है कि यह प्राकृतिक और सहज महसूस करने के लिए कितना मुश्किल है।कैलिबर में कन्वेंशन। रेडियो बटन के लिए माइक्रोरो

क्या कोई इस सम्मेलन के अच्छे कार्यान्वयन के बारे में जानता है?

उत्तर

0

मुझे ऐसा लगता है, यह आप के लिए पूरा उपयोग करते हैं: -

<UserControl x:Class="CaliburnMicroTest.Views.RadioButtonTestView" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     d:DesignHeight="300" 
     d:DesignWidth="300" 
     mc:Ignorable="d"> 
<StackPanel> 
    <RadioButton Name="NewInstallChecked" 
       Margin="75,10,0,0" 
       Content="New Installation (default)" 
       GroupName="InstallType" /> 
    <RadioButton Name="UpdateInstallChecked" 
       Margin="75,10,0,0" 
       Content="Update of existing Installation" 
       GroupName="InstallType" /> 
    <Label Name="label2" 
      Height="28" 
      Margin="20,20,0,0" 
      HorizontalAlignment="Left" 
      VerticalAlignment="Top" 
      Content="Please select which version of Siseco you want to install:" /> 
    <RadioButton Name="ServerChecked" 
       Margin="75,10,0,0" 
       Content="Server version (default)" 
       GroupName="Version" /> 
    <RadioButton Name="ClientChecked" 
       Margin="75,10,0,0" 
       Content="Client version" 
       GroupName="Version" /> 
    <StackPanel Margin="10" Orientation="Horizontal"> 
     <Button Name="SaveAndClose" 
       Width="80" 
       Content="Ok" /> 
     <Button Name="TryClose" 
       Width="80" 
       Content="Cancel" /> 
    </StackPanel> 
</StackPanel></UserControl> 




public class RadioButtonTestViewModel : Screen 
{ 
    private bool newInstallChecked; 
    private bool updateInstallChecked; 
    private bool serverChecked; 
    private bool clientChecked; 

    public bool NewInstallChecked 
    { 
     get { return newInstallChecked; } 
     set 
     { 
      if (value.Equals(newInstallChecked)) return; 
      newInstallChecked = value; 
      NotifyOfPropertyChange(() => NewInstallChecked); 
     } 
    } 

    public bool UpdateInstallChecked 
    { 
     get { return updateInstallChecked; } 
     set 
     { 
      if (value.Equals(updateInstallChecked)) return; 
      updateInstallChecked = value; 
      NotifyOfPropertyChange(() => UpdateInstallChecked); 
     } 
    } 

    public bool ServerChecked 
    { 
     get { return serverChecked; } 
     set 
     { 
      if (value.Equals(serverChecked)) return; 
      serverChecked = value; 
      NotifyOfPropertyChange(() => ServerChecked); 
     } 
    } 

    public bool ClientChecked 
    { 
     get { return clientChecked; } 
     set 
     { 
      if (value.Equals(clientChecked)) return; 
      clientChecked = value; 
      NotifyOfPropertyChange(() => ClientChecked); 
     } 
    } 

    public void SaveAndClose() 
    { 
     Options.Client = ClientChecked; 
     Options.NewInstall = NewInstallChecked; 

     Options.Server = ServerChecked; 
     Options.UpdateInstall = UpdateInstallChecked; 

     TryClose(); 
    } 

    protected override void OnInitialize() 
    { 
     base.OnInitialize(); 

     ClientChecked = Options.Client; 
     NewInstallChecked = Options.NewInstall; 

     ServerChecked = Options.Server; 
     UpdateInstallChecked = Options.UpdateInstall; 
    } 

    public static class Options 
    { 
     public static bool NewInstall { get; set; } 
     public static bool UpdateInstall { get; set; } 

     public static bool Server { get; set; } 
     public static bool Client { get; set; } 
    }}