【发布时间】:2015-11-19 19:35:33
【问题描述】:
我将三个单选按钮(使用 Caliburn.Micro)绑定到视图模型的三个属性。所有属性似乎都正确,我调试以查看所选属性返回 True 并且控件具有 IsChecked = true 并且属性通知器似乎正在提高,但是当我第一次打开表单时,没有任何切换按钮出现选中.如果我开始单击它们,一切正常,只有在初始加载时所选值没有被“按下”。这是 XAML...
<RadioButton GroupName="Alignment" Name="FooterLeftAlign" Style="{StaticResource {x:Type ToggleButton}}" Margin="0,0,5,0">
<Image Source="pack://application:,,,/DevExpress.Images.v15.1;component/Images/Format/AlignLeft_16x16.png" Margin="0" />
</RadioButton>
<RadioButton GroupName="Alignment" Name="FooterCenterAlign" Style="{StaticResource {x:Type ToggleButton}}" Margin="0,0,5,0">
<Image Source="pack://application:,,,/DevExpress.Images.v15.1;component/Images/Format/AlignCenter_16x16.png" Margin="0" />
</RadioButton>
<RadioButton GroupName="Alignment" Name="FooterRightAlign" Style="{StaticResource {x:Type ToggleButton}}" Margin="0,0,5,0">
<Image Source="pack://application:,,,/DevExpress.Images.v15.1;component/Images/Format/AlignRight_16x16.png" Margin="0" />
</RadioButton>
这里是属性...
public bool FooterLeftAlign {
get {
return (ScannerSettings.StampOptions.TextAlign == TextAlignment.Left);
}
set {
if (value) {
ScannerSettings.StampOptions.TextAlign = TextAlignment.Left;
RaisePropertyChanged(() => FooterLeftAlign);
}
}
}
public bool FooterCenterAlign {
get {
return (ScannerSettings.StampOptions.TextAlign == TextAlignment.Center);
}
set {
if (value) {
ScannerSettings.StampOptions.TextAlign = TextAlignment.Center;
RaisePropertyChanged(() => FooterCenterAlign);
}
}
}
public bool FooterRightAlign {
get {
return (ScannerSettings.StampOptions.TextAlign == TextAlignment.Right);
}
set {
if (value) {
ScannerSettings.StampOptions.TextAlign = TextAlignment.Right;
RaisePropertyChanged(() => FooterRightAlign);
}
}
}
我什至在这个表单上有一些实际的切换按钮,用于粗体、斜体等......它们工作正常。我已经看到很多使用触发器强制自定义样式的示例,但我想确保它看起来像其他切换按钮。由于我见过与此非常相似的其他示例,我唯一能想到的是我们有一个 DevExpress 主题,但找不到任何看起来会改变这种行为的东西。
如果有人有任何建议,将不胜感激。
【问题讨论】:
-
那些单选按钮似乎没有将 IsChecked 绑定到任何东西...您是在其他地方设置它们的值吗?
-
抱歉,感谢您指出这一点,它们是使用 Caliburn.Micro 绑定的。
标签: c# wpf xaml devexpress caliburn.micro