-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Search TextBlock horizontal alignment centered #1954
Conversation
@Benglin for review please |
Hi @aosyatnik, thanks for the pull request, I hope it familiarizes yourself with GitHub, which is a good start. While the code changes worked well as the first cut, we need to change a little more things here to match the design as outlined in the specification: Here are my suggestions:
That way you can align both the |
Hi, Ben.
|
No worries, @aosyatnik, in my opinion |
…SearchTextBoxGrid_MouseEnter" and "SearchTextBoxGrid_MouseLeave" was changed due to needs of moving icon and text block. Now when mouse moves on SearchTextBoxGrid StackPanel moves at the left side.
Hi @aosyatnik, I have tried this out and spoken to @elayabharath, this is the desired behaviour:
As much as possible we should do this within XAML with the help of Please let me know if there's anything that's not clear and I'll clarify. |
…so alignment now depends on Converters class. There is c# code only in Conventers class and there is only one method in SearchView - SearchTextBox_MouseDown.
@@ -179,7 +179,7 @@ public class NonEmptyStringToCollapsedConverter : IValueConverter | |||
public object Convert(object value, Type targetType, object parameter, | |||
CultureInfo culture) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This converter is used in various places, please don't change its original intent. We need a different solution.
…, I have tried to use Focus of TextBox as Binding element, but there is one problem: if we have some text in textbox and than lose focus, our icon appears at the center. That's why using focus for binding is wrong solution. What I propose is to create new property in ViewModel. I called it CanAlingmentToLeft, that would depend not only on Focus, but also on value of textbox. Hope that you will accept this solution.
In the last Vladimir's commit changes about actions was removed. I have tried to use Focus of TextBox as Binding element, but there is one problem: if we have some text in textbox and than lose focus, our icon appears at the center. That's why using focus for binding is wrong solution. What I propose is to create new property in ViewModel. I called it CanAlingmentToLeft, that would depend not only on Focus, but also on value of textbox. Hope that you will accept this solution. |
@@ -55,6 +55,17 @@ public string SearchText | |||
} | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now SearchIconAlignment
property that is bound to StackPanel.HorizontalAlignment
as described in my earlier comment regarding the updated XAML. It should return System.Windows.HorizontalAlignment
in this case:
public System.Windows.HorizontalAlignment SearchIconAlignment { get { ... } set { ... } };
Hi @aosyatnik, thanks for the updates. After getting your codes and tweaked it for a while, I think I have found a better way to do that (instead of using My suggestion: Here is the XAML for the search part that we need for this change: <Grid Name="SearchTextBoxGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Name="SearchIconAndTextBlockPanel"
Grid.ColumnSpan="2"
Width="Auto">
<StackPanel.HorizontalAlignment>
<Binding Path="SearchIconAlignment" ... />
</StackPanel.HorizontalAlignment>
<Image x:Name="SearchIcon" ... />
<TextBlock ... />
</StackPanel>
<TextBox Name="SearchTextBox" ... />
<Button Name="SearchCancelButton"
Grid.Column="1" />
</Grid> Few things that you notice here:
Whenever focus changes or text changes in Please try it out and see if things are working as expected. Also, please remove unnecessary attributes from these XAML tags, something like |
One other thing, could you format the XAML part that you are working on? Each attribute should be on its own line (except the first attribute). Here's how:
You can repeat steps #5 and #6 each time you change XAML so that they are always formatted properly. Thanks! WARNING: Do not change other parts that you are not working on, that will result in too much diff for code review. |
@@ -330,6 +333,20 @@ private void SearchTextBoxGrid_MouseLeave(object sender, MouseEventArgs e) | |||
SearchIcon.Source = new BitmapImage(searchIconSource); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the statement after if
or else
condition to a new line, so it doesn't get too long.
Hi @aosyatnik, thanks for the changes, they look great now! Anyway, I can't merge your changes, you need to pull in new updates. Also since you're going to need another commit, you can incorporate the changes I request above too. |
… white-space was deleted. It's ready for merge.
As well as source code was changed, I have added all changes to my project. Now it's exact copy as Sitrus + my changes about SearchTextBox. I hope there won't be any problems about merging them now. |
Closing this as it is replaced by another pull request. |
No description provided.