15,904,155 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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
Steve15f
2-Oct-17 10:11am
View
Deleted
Thank you for your reply.
But, sorry, i'm lost. In your solution 1, it's one solution, or multiple solution to choice ?
Thank you
Steve15f
2-Oct-17 9:13am
View
Thank you for your reply. Sorry for my english too.
I would to modifiy my checkbox to button style. I used this :
<CheckBox x:Name="cbxIlots" Tag="{Binding strCodeIlot}" Style="{StaticResource {x:Type ToggleButton}}" Content="{Binding strDesIlot}" FontSize="14" Margin="25,15,25,15" Width="225" Height="45" IsChecked="{Binding bChecked}" Checked="cbxIlots_Checked" Unchecked="cbxIlots_Unchecked" />
I set the style "togglebutton" to my checkbox.
It's work, great.
But i need to have a button, with two text, for example, TITLE, Font size 14, bold and below, a text, for example, DESCRIPTION, Font size 10, italic.
And, if my checkbox is checked, an image with background blue, and is not checked, with background purple, for example.
How i do make this ?
Thank you in advance. If the good solution is to not use a user control i would use the great solution to get my result.
I can work with this code on my main project XAML :
<Window x:Class="Plutus.SelectionIlot"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:BoutonsSelection;assembly=BoutonsSelection"
Title="Sélection d'ilot" Height="367" Width="884" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" ShowInTaskbar="False" Icon="PlutusIcone.ico">
<window.resources>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type CheckBox}">
<StackPanel Orientation="Horizontal">
<Image x:Name="checkboxImage" Source="Images/btnNormal.png" Width="32"/>
<ContentPresenter/>
</stackpanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="checkboxImage" Property="Source" Value="Images/btnChecked.png"/>
</trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsChecked" Value="False"/>
</multitrigger.Conditions>
<!--<Setter TargetName="checkboxImage" Property="Source" Value="hover.png"/>-->
</multitrigger>
</controltemplate.Triggers>
</controltemplate>
</setter.Value>
</setter>
<grid>
<grid.columndefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<grid.rowdefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.85*" />
<RowDefinition Height="0.15*" />
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="1" >
<ItemsControl x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="1" Background="{x:Null}" ItemsSource="{Binding LstIlots}" Grid.ColumnSpan="4" Foreground="White">
<itemscontrol.itemtemplate>
<datatemplate>
<Border BorderBrush="White" BorderThickness="1" CornerRadius="3" Margin="0,3" Grid.ColumnSpan="0" Background="Transparent" HorizontalAlignment="Left" Vert
Steve15f
2-Oct-17 8:32am
View
Yes, sorry, i will say user control
My control work, but i need a property IsChecked too
Yes, i come from Winforms.
Can you give me more information ?
I created a DLL with my custom control. It's not correct ?
I created a project type library of user controle WPF and i insert my DLL on my project.
It's ok but i don't have the property checked
Steve15f
2-Oct-17 4:40am
View
Hello
In my C# User Control i have
public bool IsChecked
{
get { return (bool)GetValue(IsCheckedProperty); }
set { SetValue(IsCheckedProperty, value); }
}
I need to check / uncheck my button if bChecked is true or false
Thank you
Steve15f
22-Sep-17 4:02am
View
Great thank you
I begin to understand binding!
Thank you very much
Steve15f
22-Sep-17 3:44am
View
Hello
Just, how make this : Then, loop over your collection
I have add this code , when i learn for my data on my another topic
public partial class SelectionLigne : Window, INotifyPropertyChanged
{
#region Évenement qui permet de déclencher l'événement INotifyPropertyChanged et mettre à jour le binding
public void Set<tvalue>(ref TValue field, TValue newValue, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer<tvalue>.Default.Equals(field, default(TValue)) || !field.Equals(newValue))
{
field = newValue;
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private bool IsChecked;
public bool bChecked
{
get { return IsChecked; }
set { Set(ref IsChecked, value); }
}
Steve15f
21-Sep-17 10:54am
View
Ok, thank you , it's great, it's work.
But i have a problem now with this variable :
private string _strTotaux;
public string strTotaux
{
get { return _strTotaux; }
set { _strTotaux = value; }
}
it no view in my screen, but before the modification it's ok
I don't understand why
I don't have any error of bindings
I need to use NotifyChangedProperty when i fill my variable ?
strTotaux = "Nb OPs : " + dblTotalOp.ToString() + " Qte totale : " + dblTotalQte.ToString() + " Pces Temps total : " + dblTotalTemps + " Hrs";
Steve15f
21-Sep-17 10:32am
View
Thank you
If i understand, i add the code
public class RangeObservableCollection<t> : ObservableCollection<t>
{
private bool _suppressNotification = false;
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
{
if (!_suppressNotification)
base.OnCollectionChanged(e);
}
public void AddRange(IEnumerable<t> list)
{
if (list == null)
throw new ArgumentNullException("list");
_suppressNotification = true;
foreach (T item in list)
{
Add(item);
}
_suppressNotification = false;
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
In my MainWindow.xaml.cs ?
But i don't understand how i call AddRange, sorry :(
It's my first week in WPF
Steve15f
21-Sep-17 10:22am
View
Sorry but i don't see a link
I tried to use .AddRange but it's not possible on an observablecollection
I see
Steve15f
21-Sep-17 10:02am
View
Hello
Thank you for your reply
I don't have *.AddRange.
I have only _lstOperations.Add
Because, it's not a list, it's an ObservableCollection
Thank you
Steve15f
21-Sep-17 9:16am
View
Hello
Thank you very very much
But, this solution has create a small new problem
Can you please read my topic :
https://www.codeproject.com/Questions/1207251/Csharp-WPF-refresh-ecran
If you look this topic (sum) you can see my first code, with the datacontext with the list is ok, but now, we changed the datacontext with this thank you
Steve15f
21-Sep-17 4:10am
View
Thank you very much
I have an error on this :
public ObservableCollection<cl_operation> lstOperationsTemp { get; set; } = new ObservableCollection<cl_operation>();
Error 1 Invalid '=' token in the declaration of members of the class, structure, or interface
Error 1 Invalid '(' token in the declaration of members of the class, structure, or interface
EDIT : this code Work :
private ObservableCollection<cl_operation> _lstOperationsTemp = new ObservableCollection<cl_operation>();
public ObservableCollection<cl_operation> LstOperationsTemp
{
get { return _lstOperationsTemp; }
set
{
_lstOperationsTemp = value;
}
}
In XAML :
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="3" >
<ItemsControl VerticalAlignment="Top" x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}" ItemsSource="{Binding LstOperationsTemp}" Foreground="White">
It's work, i see my data in my grid but, in my label, my strTotaux didn't show :
Steve15f
21-Sep-17 2:32am
View
Deleted
I think the problem is with my
public ObservableCollection<cl_operation> lstOperationsTemp = new ObservableCollection<cl_operation>();
This code is in my public partial class MainWindow : Window
I don't understand how change this
I don't have any binding errors
Sorry for my english
Thank you
Steve15f
21-Sep-17 1:53am
View
I work on a copy of my project. But i don't find why it's doesnt work
I removed this DataContext :
Application.Current.Dispatcher.Invoke(new Action(() => this.DataContext = lstOperations));
and i replace by this :
DataContext = this; in MainWindow()
In my XAML i specify ItemsSource="{Binding CL_Operation}" in my <ItemsControl ItemsSource="{Binding CL_Operation}">
Now i don't have any data in my view
I test, i check, i try to understand, sorry... thank you for your help
Steve15f
21-Sep-17 1:47am
View
Hello, thank you.
I changed DataContext = this, it's ok.
In my XAML i change this code :
<ItemsControl VerticalAlignment="Top" x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}" ItemsSource="{Binding}" Foreground="White">
by this code :
<ItemsControl VerticalAlignment="Top" x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}" ItemsSource="{Binding CL_Operation}" Foreground="White">
But my data view in my screen is empty now. I have two binding errors :
System.Windows.Data Error: 40 : BindingExpression path error: 'CL_Operation' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=CL_Operation; DataItem='MainWindow' (Name=''); target element is 'ItemsControl' (Name='lvDataBinding'); target property is 'ItemsSource' (type 'IEnumerable')
System.Windows.Data Error: 40 : BindingExpression path error: 'strTotaux' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=strTotaux; DataItem='MainWindow' (Name=''); target element is 'Label' (Name=''); target property is 'Content' (type 'Object')
If you need i can send my XAML in .txt file
Steve15f
21-Sep-17 1:34am
View
Graeme_Grant
For the DataContext i haven't nothing modify. I set always the datacontext :
Application.Current.Dispatcher.Invoke(new Action(() => this.DataContext = lstOperations));
In my void GetList();
I don't have any binding errors
Thank you
Steve15f
21-Sep-17 1:26am
View
Hello
Thank you very much for your reply.
But, i don't understand, why the new syntax do not work ? With the old syntax it's ok.
I'm using Visual Sutdio 2012, it's the reason ?
For my problem : i see my data in the view, before it's worked too.
With your code, it's fastly than with my code.
But my problem is not solved.
In my label in XAML with my binding strTotaux, it's always the registre [0] to display of my classe CL_Operation, but nut the sum
I calculate the sum in my for loop :
dblTotalQte += Convert.ToDouble(dvOps[i]["QtePoste"].ToString().Trim());
dblTotalTemps += Convert.ToDouble(dvOps[i]["TpsChargePoste"].ToString().Trim());
dblTotalOp++;
clOp.strTotaux = "Nb OPs : " + dblTotalOp.ToString() + " Qte totale : " + dblTotalQte.ToString() + " Pces Temps total : " + dblTotalTemps + " Hrs";
Thank you.
Steve15f
21-Sep-17 1:07am
View
Hello, yes, it's work :
public class CL_Operation : ObservableBase is ok.
I have an error on
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); and on
get => _strRetardAvanceText;
Thank you very much, very much very much
Steve15f
21-Sep-17 0:58am
View
Hello
Thank you for your reply
I have error on :
PropertyChanged?.Invoke :
Invalid expression term '.'
only an assignment, call, increment, decrement, expectation, and new object expressions can be used as a statement
the name 'Invoke' does not exist in the current context
Syntax error, ':' expected
In my classe i have an error :
get => _strWidth; : error on "=>" : { or ; excepted
Thank you very much in advance.
Steve15f
20-Sep-17 5:06am
View
Hello
Ok, i can try, my english is very bad.
Show More