템플릿 10을 사용하여 UWP 응용 프로그램을 만들고 있습니다. 이와 같이 사용자 정의 컨트롤을 만들었습니다. 템플릿을 사용하여 UWP 응용 프로그램에서 사용자 제어 상태 유지 10
<my:DeviceInfoUserControl OnEndpointTypeChange="{Binding OnEndpointTypeChangeCommand}" Component="{Binding DeviceManagementViewModel,Mode=TwoWay}"></my:DeviceInfoUserControl>
나는 사용자 정의 컨트롤에 라디오 버튼이 있습니다. 여러 화면에 사용자 정의 컨트롤을 추가했습니다.
다음과 같이 사용자 제어가 자신의 뷰 모델뿐만 아니라 일부 종속성 속성이 있습니다
public class DeviceManagementViewModel : ViewModelBase
{
}
public sealed partial class DeviceInfoUserControl : UserControl
{
public bool IsToggled = true;
public DeviceInfoUserControl()
{
this.InitializeComponent();
}
public static readonly DependencyProperty OnEndpointTypeChangeProperty =
DependencyProperty.Register(
"OnEndpointTypeChange",
typeof(ICommand),
typeof(DeviceInfoUserControl), new PropertyMetadata(null));
public ICommand OnEndpointTypeChange
{
get { return (ICommand)GetValue(OnEndpointTypeChangeProperty); }
set { SetValue(OnEndpointTypeChangeProperty, value); }
}
public static readonly DependencyProperty ComponentProperty = DependencyProperty.Register("Component", typeof(DeviceManagementViewModel), typeof(DeviceInfoUserControl), new PropertyMetadata(null));
public DeviceManagementViewModel Component
{
get { return (DeviceManagementViewModel)GetValue(ComponentProperty); }
set { SetValue(ComponentProperty, value); }
}
}
내가 모든 화면을 통해 라디오 버튼 선택을 보존하고자합니다. 어떻게해야합니까?
그렇게 :
그리고 사용자 정의 컨트롤에
당신은 모든 공동의 라디오 버튼을 선택하고 싶습니다. 한 번의 클릭으로 ntrol? –예 ... 전 세계적으로 액세스 할 수있는 뷰 모델과 같은 것 ... 라디오 버튼을 선택하면 선택 항목이 모든 곳에 반영됩니다. –
SessionState가 ViewModelBase에 내장 됨 – mvermef