Click here to Skip to main content
15,896,269 members

Comments by Steve15f (Top 25 by date)

Steve15f 25-Jun-18 1:06am View    
Hi
What do i need to change ? Thank you.
Steve15f 3-Oct-17 7:01am View    
Yes i realize. Thank you !

But, why this code don't work ?

private void Button_Click(object sender, RoutedEventArgs e)
{
usercontrol1.IsChecked = !usercontrol1.IsChecked;
customcontrol.IsChecked = !customcontrol.IsChecked;
checkbox.IsChecked = !checkbox.IsChecked;
}
Steve15f 3-Oct-17 4:03am View    
Hello
An example.

I would this result :

http://nsa39.casimages.com/img/2017/10/03/171003103015495315.png

It's ok with my solution write in mmy first message

But, with your solution, i have this result :

http://nsa39.casimages.com/img/2017/10/03/171003103015578367.png

Thank you
Steve15f 2-Oct-17 10:46am View    
Thank you. I tried.

But, it's not the result waited.

I have a checkbox, not a button.

Even, it's ok, i succeed to display every checkbox with my datacontext.

This code do not work :


private void Button_Click(object sender, RoutedEventArgs e)
{
usercontrol1.IsChecked = !usercontrol1.IsChecked;
customcontrol.IsChecked = !customcontrol.IsChecked;
checkbox.IsChecked = !checkbox.IsChecked;
}

the name usercontrol1 do not exist in the actual context

thank you !
Steve15f 2-Oct-17 10:18am View    
Thank you very much.

I add in my project : a User Control WPF.

In this XAML :

<UserControl x:Class="Plutus.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Plutus"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel Background="White" Width="301">
<textblock> UserControl - a composition of existing Controls
<CheckBox x:Name="checkbox" Content="I represent the checked state">



In this Behind C# :

public bool IsChecked
{
get { return (bool)GetValue(IsCheckedProperty); }
set
{
SetValue(IsCheckedProperty, value);
checkbox.IsChecked = value;
}
}

// Using a DependencyProperty as the backing store for IsChecked. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsCheckedProperty =
DependencyProperty.Register("IsChecked", typeof(bool), typeof(UserControl1), new PropertyMetadata(false));

Correct ?

In my project XAML :

<stackpanel>

<local:UserControl1 x:Name="usercontrol1">



<CheckBox x:Name="checkbox" Content="I'm cooler - using MVVM and let the WPF do the rest" IsChecked="{Binding IsChecked}">





In my behind c#

private void Button_Click(object sender, RoutedEventArgs e)
{
//UserControl.IsChecked = !UserControl1.IsChecked;
//customcontrol.IsChecked = !customcontrol.IsChecked;
//checkbox.IsChecked = !checkbox.IsChecked;

}
Correct ?

Thank you